public static Annotation[] callGetDeclaredAnnotations(Class thiz) { return thiz.getDeclaredAnnotations(); }
@Override protected List<ClassStructure> initialValue() { return Collections.unmodifiableList(newInstances(getAnnotationTypeArray(clazz.getDeclaredAnnotations()))); } };
public List<Annotation> callClassGetDeclaredAnnotations(Class<?> c) { return Arrays.asList(c.getDeclaredAnnotations()); } public boolean callClassIsAnnotationPresent(Class<?> c, Class<? extends Annotation> annotClass) {
/** Returns an array of {@link Annotation} objects reflecting all annotations declared by the supplied class, or an empty * array if there are none. Does not include inherited annotations. */ static public Annotation[] getDeclaredAnnotations (Class c) { java.lang.annotation.Annotation[] annotations = c.getDeclaredAnnotations(); Annotation[] result = new Annotation[annotations.length]; for (int i = 0; i < annotations.length; i++) { result[i] = new Annotation(annotations[i]); } return result; }
private static boolean isConfigStoreWithStableVersion(ConfigStore cs) { for (Annotation annotation : cs.getClass().getDeclaredAnnotations()) { if (annotation instanceof ConfigStoreWithStableVersioning) { return true; } } return false; }
/** Returns an {@link Annotation} object reflecting the annotation provided, or null if this class doesn't have such an * annotation. This is a convenience function if the caller knows already which annotation type he's looking for. */ static public Annotation getDeclaredAnnotation (Class c, Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = c.getDeclaredAnnotations(); for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) return new Annotation(annotation); } return null; }
/** Returns an array of {@link Annotation} objects reflecting all annotations declared by the supplied class, or an empty * array if there are none. Does not include inherited annotations. */ static public Annotation[] getDeclaredAnnotations (Class c) { java.lang.annotation.Annotation[] annotations = c.getDeclaredAnnotations(); Annotation[] result = new Annotation[annotations.length]; for (int i = 0; i < annotations.length; i++) { result[i] = new Annotation(annotations[i]); } return result; }
/** Returns an {@link Annotation} object reflecting the annotation provided, or null if this class doesn't have such an * annotation. This is a convenience function if the caller knows already which annotation type he's looking for. */ static public Annotation getDeclaredAnnotation (Class c, Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = c.getDeclaredAnnotations(); for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) return new Annotation(annotation); } return null; }
/** * @since 2.7 */ public static Annotation[] findClassAnnotations(Class<?> cls) { if (isObjectOrPrimitive(cls)) { return NO_ANNOTATIONS; } return cls.getDeclaredAnnotations(); }
/** * @since 2.7 */ public static Annotation[] findClassAnnotations(Class<?> cls) { if (isObjectOrPrimitive(cls)) { return NO_ANNOTATIONS; } return cls.getDeclaredAnnotations(); }
private static <A extends Annotation> void getSuperAnnotations(Class<A> annotationType, Set<Annotation> visited) { Annotation[] anns = annotationType.getDeclaredAnnotations(); for (Annotation ann : anns) { if (!ann.annotationType().getName().startsWith("java.lang") && visited.add(ann)) { getSuperAnnotations(ann.annotationType(), visited); } } }
public static <T extends Annotation> Optional<T> getAnnotation(Class<?> type, Class<T> annotation) { Validate.notNull(annotation, "annotation cannot be null"); Validate.notNull(type, "type cannot be null"); for (Annotation ann : type.getDeclaredAnnotations()) { if (ann.annotationType().equals(annotation)) return Optional.of((T) ann); } Class<?> superType = type.getSuperclass(); if (superType != null && !superType.equals(Object.class)) { return getAnnotation(superType, annotation); } return Optional.absent(); }
public List<String> getClassAnnotationNames(Class aClass) { return getAnnotationNames(aClass.getDeclaredAnnotations()); }
/** * @since 2.7 */ public static Annotation[] findClassAnnotations(Class<?> cls) { if (isObjectOrPrimitive(cls)) { return NO_ANNOTATIONS; } return cls.getDeclaredAnnotations(); }
/** * {@inheritDoc} */ @CachedReturnPlugin.Enhance("declaredAnnotations") public AnnotationList getDeclaredAnnotations() { return new AnnotationList.ForLoadedAnnotations(type.getDeclaredAnnotations()); }
for (Annotation composedAnn : clazz.getDeclaredAnnotations()) { Class<? extends Annotation> composedType = composedAnn.annotationType(); if (!AnnotationUtils.isInJavaLangAnnotationPackage(composedType.getName()) && visited.add(composedAnn)) {
for (Annotation composedAnnotation : clazz.getDeclaredAnnotations()) { if (!AnnotationUtils.isInJavaLangAnnotationPackage(composedAnnotation) && visited.add(composedAnnotation)) { UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
@Test public void getValueFromNonPublicAnnotation() throws Exception { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertEquals(1, declaredAnnotations.length); Annotation annotation = declaredAnnotations[0]; assertNotNull(annotation); assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName()); assertEquals(42, getValue(annotation, VALUE)); assertEquals(42, getValue(annotation)); }
@Test public void getDefaultValueFromNonPublicAnnotation() { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertEquals(1, declaredAnnotations.length); Annotation annotation = declaredAnnotations[0]; assertNotNull(annotation); assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName()); assertEquals(-1, getDefaultValue(annotation, VALUE)); assertEquals(-1, getDefaultValue(annotation)); }
@Override public Result process(final EntityProcessorContext context) { switch (context.getType()) { case CLASS_READER: case CLASS_WRITER: addGlobalScopes(EntityFilteringHelper.getFilteringScopes(context.getEntityClass().getDeclaredAnnotations()), context.getEntityGraph()); break; default: // NOOP. break; } return super.process(context); }