
com.mageddo.featureswitch.AnnotationUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of feature-switch Show documentation
Show all versions of feature-switch Show documentation
Simplify Consumer And Producer Configuration
The newest version!
package com.mageddo.featureswitch;
import java.lang.annotation.Annotation;
public final class AnnotationUtils {
private AnnotationUtils() {}
public static A getAnnotation(Feature feature, Class 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 e) {
// ignore
} catch (NoSuchFieldException e) {
// ignore
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy