/** * Provides a new annotation instance. * @param annotationType the annotation type definition * @param elements name-value pairs representing elements of the annotation * @return a new annotation instance */ public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements) { AnnotationFactory factory = new AnnotationFactory(annotationType, elements); return (A) Proxy.newProxyInstance(annotationType.getClassLoader(), new Class[]{annotationType}, factory); }
/** * New instances should not be created directly, use factory method * {@link #createAnnotation(Class, AnnotationMember[]) createAnnotation()} * instead. * * @param klzz class defining the annotation type * @param values actual element values */ private AnnotationFactory(Class<? extends Annotation> klzz, AnnotationMember[] values) { klazz = klzz; AnnotationMember[] defs = getElementsDescription(klazz); if (values == null) { elements = defs; } else { //merge default and actual values elements = new AnnotationMember[defs.length]; next: for (int i = elements.length - 1; i >= 0; i--) { for (AnnotationMember val : values) { if (val.name.equals(defs[i].name)) { elements[i] = val.setDefinition(defs[i]); continue next; } } elements[i] = defs[i]; } } }
AnnotationMember[] defs = getElementsDescription(klazz); AnnotationMember[] old = elements; List<AnnotationMember> merged = new ArrayList<AnnotationMember>(defs.length + old.length);
/** * Provides a new annotation instance. * @param annotationType the annotation type definition * @param elements name-value pairs representing elements of the annotation * @return a new annotation instance */ public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements) { AnnotationFactory factory = new AnnotationFactory(annotationType, elements); return (A) Proxy.newProxyInstance(annotationType.getClassLoader(), new Class[]{annotationType}, factory); }
/** * New instances should not be created directly, use factory method * {@link #createAnnotation(Class, AnnotationMember[]) createAnnotation()} * instead. * * @param klzz class defining the annotation type * @param values actual element values */ private AnnotationFactory(Class<? extends Annotation> klzz, AnnotationMember[] values) { klazz = klzz; AnnotationMember[] defs = getElementsDescription(klazz); if (values == null) { elements = defs; } else { //merge default and actual values elements = new AnnotationMember[defs.length]; next: for (int i = elements.length - 1; i >= 0; i--) { for (AnnotationMember val : values) { if (val.name.equals(defs[i].name)) { elements[i] = val.setDefinition(defs[i]); continue next; } } elements[i] = defs[i]; } } }
/** * Provides a new annotation instance. * @param annotationType the annotation type definition * @param elements name-value pairs representing elements of the annotation * @return a new annotation instance */ public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements) { AnnotationFactory factory = new AnnotationFactory(annotationType, elements); return (A) Proxy.newProxyInstance(annotationType.getClassLoader(), new Class[]{annotationType}, factory); }
/** * New instances should not be created directly, use factory method * {@link #createAnnotation(Class, AnnotationMember[]) createAnnotation()} * instead. * * @param klzz class defining the annotation type * @param values actual element values */ private AnnotationFactory(Class<? extends Annotation> klzz, AnnotationMember[] values) { klazz = klzz; AnnotationMember[] defs = getElementsDescription(klazz); if (values == null) { elements = defs; } else { //merge default and actual values elements = new AnnotationMember[defs.length]; next: for (int i = elements.length - 1; i >= 0; i--) { for (AnnotationMember val : values) { if (val.name.equals(defs[i].name)) { elements[i] = val.setDefinition(defs[i]); continue next; } } elements[i] = defs[i]; } } }
/** * Provides a new annotation instance. * @param annotationType the annotation type definition * @param elements name-value pairs representing elements of the annotation * @return a new annotation instance */ public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements) { AnnotationFactory factory = new AnnotationFactory(annotationType, elements); return (A) Proxy.newProxyInstance(annotationType.getClassLoader(), new Class[]{annotationType}, factory); }
/** * New instances should not be created directly, use factory method * {@link #createAnnotation(Class, AnnotationMember[]) createAnnotation()} * instead. * * @param klzz class defining the annotation type * @param values actual element values */ private AnnotationFactory(Class<? extends Annotation> klzz, AnnotationMember[] values) { klazz = klzz; AnnotationMember[] defs = getElementsDescription(klazz); if (values == null) { elements = defs; } else { //merge default and actual values elements = new AnnotationMember[defs.length]; next: for (int i = elements.length - 1; i >= 0; i--) { for (AnnotationMember val : values) { if (val.name.equals(defs[i].name)) { elements[i] = val.setDefinition(defs[i]); continue next; } } elements[i] = defs[i]; } } }
/** * Provides a new annotation instance. * @param annotationType the annotation type definition * @param elements name-value pairs representing elements of the annotation * @return a new annotation instance */ public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements) { AnnotationFactory factory = new AnnotationFactory(annotationType, elements); return (A) Proxy.newProxyInstance(annotationType.getClassLoader(), new Class[]{annotationType}, factory); }
/** * New instances should not be created directly, use factory method * {@link #createAnnotation(Class, AnnotationMember[]) createAnnotation()} * instead. * * @param klzz class defining the annotation type * @param values actual element values */ private AnnotationFactory(Class<? extends Annotation> klzz, AnnotationMember[] values) { klazz = klzz; AnnotationMember[] defs = getElementsDescription(klazz); if (values == null) { elements = defs; } else { //merge default and actual values elements = new AnnotationMember[defs.length]; next: for (int i = elements.length - 1; i >= 0; i--) { for (AnnotationMember val : values) { if (val.name.equals(defs[i].name)) { elements[i] = val.setDefinition(defs[i]); continue next; } } elements[i] = defs[i]; } } }
/** * Provides a new annotation instance. * @param annotationType the annotation type definition * @param elements name-value pairs representing elements of the annotation * @return a new annotation instance */ public static <A extends Annotation> A createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements) { AnnotationFactory factory = new AnnotationFactory(annotationType, elements); return (A) Proxy.newProxyInstance(annotationType.getClassLoader(), new Class[]{annotationType}, factory); }
/** * New instances should not be created directly, use factory method * {@link #createAnnotation(Class, AnnotationMember[]) createAnnotation()} * instead. * * @param klzz class defining the annotation type * @param values actual element values */ private AnnotationFactory(Class<? extends Annotation> klzz, AnnotationMember[] values) { klazz = klzz; AnnotationMember[] defs = getElementsDescription(klazz); if (values == null) { elements = defs; } else { //merge default and actual values elements = new AnnotationMember[defs.length]; next: for (int i = elements.length - 1; i >= 0; i--) { for (AnnotationMember val : values) { if (val.name.equals(defs[i].name)) { elements[i] = val.setDefinition(defs[i]); continue next; } } elements[i] = defs[i]; } } }