FieldId(TypeId<D> declaringType, TypeId<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }
MethodId(TypeId<D> declaringType, TypeId<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
/** * Convert a value of an element to a {@code Constant}. * <p><strong>Warning:</strong> Array or TypeId value is not supported yet. * * @param value an annotation element value. * @return a Constant */ static Constant toConstant(Object value) { Class clazz = value.getClass(); if (clazz.isEnum()) { CstString descriptor = new CstString(TypeId.get(clazz).getName()); CstString name = new CstString(((Enum)value).name()); CstNat cstNat = new CstNat(name, descriptor); return new CstEnumRef(cstNat); } else if (clazz.isArray()) { throw new UnsupportedOperationException("Array is not supported yet"); } else if (value instanceof TypeId) { throw new UnsupportedOperationException("TypeId is not supported yet"); } else { return Constants.getConstant(value); } } }
/** * Set an annotation element of this instance. * If there is a preexisting element with the same name, it will be * replaced by this method. * * @param element {@code non-null;} the annotation element to be set. */ public void set(Element element) { if (element == null) { throw new NullPointerException("element == null"); } CstString pairName = new CstString(element.getName()); Constant pairValue = Element.toConstant(element.getValue()); NameValuePair nameValuePair = new NameValuePair(pairName, pairValue); elements.put(element.getName(), nameValuePair); }
interfaces.ropTypes, new CstString(sourceFile));
return CstShort.make((Short) value); } else if (value instanceof String) { return new CstString((String) value); } else if (value instanceof Class) { return new CstType(TypeId.get((Class<?>) value).ropType);
FieldId(Type<D> declaringType, Type<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }
MethodId(Type<D> declaringType, Type<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
MethodId(TypeId<D> declaringType, TypeId<R> returnType, String name, TypeList parameters) { if (declaringType == null || returnType == null || name == null || parameters == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.returnType = returnType; this.name = name; this.parameters = parameters; this.nat = new CstNat(new CstString(name), new CstString(descriptor(false))); this.constant = new CstMethodRef(declaringType.constant, nat); }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; } }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; }
/** * Interns an element into this instance. * * @param string {@code non-null;} the string to intern, as a regular Java * {@code String} * @return {@code non-null;} the interned string */ public StringIdItem intern(String string) { return intern(new StringIdItem(new CstString(string))); }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; } }
/** * Interns an element into this instance. * * @param string {@code non-null;} the string to intern, as a regular Java * {@code String} * @return {@code non-null;} the interned string */ public StringIdItem intern(String string) { return intern(new StringIdItem(new CstString(string))); }
/** * Interns an element into this instance. * * @param string {@code non-null;} the string to intern, as a regular Java * {@code String} * @return {@code non-null;} the interned string */ public StringIdItem intern(String string) { return intern(new StringIdItem(new CstString(string))); }
/** * Gets the type descriptor for this instance. * * @return {@code non-null;} the descriptor */ public CstString getDescriptor() { if (descriptor == null) { descriptor = new CstString(type.getDescriptor()); } return descriptor; } }
/** * Interns an element into this instance. * * @param string {@code non-null;} the string to intern, as a regular Java * {@code String} * @return {@code non-null;} the interned string */ public StringIdItem intern(String string) { return intern(new StringIdItem(new CstString(string))); }