FeatureAnnotations { public static <A extends Annotation> A getAnnotation(Feature feature, Class<A> annotationType) { try { Class<? extends Feature> featureClass = feature.getClass(); A fieldAnnotation = featureClass.getField(feature.name()).getAnnotation(annotationType); A classAnnotation = featureClass.getAnnotation(annotationType); return fieldAnnotation != null ? fieldAnnotation : classAnnotation; } catch (SecurityException | NoSuchFieldException e) { } return null; }  static String getLabel(Feature feature); static boolean isEnabledByDefault(Feature feature); static boolean isAnnotationPresent(Feature feature, Class<? extends Annotation> annotationType); static Set<Annotation> getAnnotations(Feature feature); static A getAnnotation(Feature feature, Class<A> annotationType); static String[] getFeatureAttribute(Annotation annotation);  }
@Test void getAnnotationWillReturnFieldLevelAnnotation() { EnabledByDefault result = FeatureAnnotations.getAnnotation(MyFeature.FEATURE_ENABLED_BY_DEFAULT, EnabledByDefault.class); assertNotNull(result); }
@Test void getAnnotationWillReturnClassLevelAnnotation() { ClassLevelGroup result = FeatureAnnotations.getAnnotation(MyFeature.FEATURE_ENABLED_BY_DEFAULT, ClassLevelGroup.class); assertNotNull(result); }
@Test void getAnnotationWillReturnNullWhenAnnotationDoesNotExist() { Label result = FeatureAnnotations.getAnnotation(MyFeature.FEATURE_ENABLED_BY_DEFAULT, Label.class); assertNull(result); }