final AnnotationInstance annotation(DotName name) { AnnotationInstance key = new AnnotationInstance(name, null, null); int i = Arrays.binarySearch(annotations, key, AnnotationInstance.NAME_COMPARATOR); return i >= 0 ? annotations[i] : null; }
final AnnotationInstance annotation(DotName name) { AnnotationInstance key = new AnnotationInstance(name, null, null); int i = Arrays.binarySearch(annotations, key, AnnotationInstance.NAME_COMPARATOR); return i >= 0 ? annotations[i] : null; }
public final AnnotationInstance annotation(DotName name) { AnnotationInstance key = new AnnotationInstance(name, null, null); int i = Arrays.binarySearch(annotations, key, AnnotationInstance.NAME_COMPARATOR); return i >= 0 ? annotations[i] : null; }
/** * Construct a new mock annotation instance. The passed values array will be defensively copied. * * @param name the name of the annotation instance * @param target the thing the annotation is declared on * @param values the values of this annotation instance * @return the new mock Annotation Instance */ public static final AnnotationInstance create(DotName name, AnnotationTarget target, AnnotationValue[] values) { if (name == null) throw new IllegalArgumentException("Name can't be null"); if (values == null) throw new IllegalArgumentException("Values can't be null"); values = values.clone(); // Sort entries so they can be binary searched Arrays.sort(values, new Comparator<AnnotationValue>() { public int compare(AnnotationValue o1, AnnotationValue o2) { return o1.name().compareTo(o2.name()); } }); return new AnnotationInstance(name, target, values); }
private AnnotationInstance readAnnotationEntry(PackedDataInputStream stream, AnnotationTarget caller) throws IOException { DotName name = nameTable[stream.readPackedU32()]; AnnotationTarget target = readAnnotationTarget(stream, caller); AnnotationValue[] values = readAnnotationValues(stream); return new AnnotationInstance(name, target, values); }
private AnnotationInstance processAnnotation(DataInputStream data, AnnotationTarget target) throws IOException { String annotation = convertClassFieldDescriptor(decodeUtf8Entry(data.readUnsignedShort())); int valuePairs = data.readUnsignedShort(); AnnotationValue[] values = new AnnotationValue[valuePairs]; for (int v = 0; v < valuePairs; v++) { String name = intern(decodeUtf8Entry(data.readUnsignedShort())); values[v] = processAnnotationElementValue(name, data); } // Sort entries so they can be binary searched Arrays.sort(values, new Comparator<AnnotationValue>() { public int compare(AnnotationValue o1, AnnotationValue o2) { return o1.name().compareTo(o2.name()); } }); DotName annotationName = names.convertToName(annotation); AnnotationInstance instance = new AnnotationInstance(annotationName, target, values); // Don't record nested annotations in index if (target != null) { recordAnnotation(classAnnotations, annotationName, instance); recordAnnotation(masterAnnotations, annotationName, instance); if (target instanceof FieldInfo || target instanceof MethodInfo || target instanceof MethodParameterInfo) { elementAnnotations.add(instance); } } return instance; }
AnnotationInstance instance = new AnnotationInstance(annotationName, target, values);
PathElement element = elements.pop(); if (element == null) { type = intern(type.addAnnotation(new AnnotationInstance(typeAnnotationState.annotation, null)));
case AVALUE_NESTED: { DotName nestedName = classTable[stream.readPackedU32()]; AnnotationInstance nestedInstance = new AnnotationInstance(nestedName, null, readAnnotationValues(stream)); value = new AnnotationValue.NestedAnnotation(name, nestedInstance); break;