All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mageddo.commons.AnnotationUtils Maven / Gradle / Ivy

There is a newer version: 1.4.9
Show newest version
package com.mageddo.commons;

import com.mageddo.togglefirst.Feature;

import java.lang.annotation.Annotation;

public final class AnnotationUtils {

	private AnnotationUtils() {}

	public static  A getAnnotation(Feature feature, Class annotationType) {
		try {
			Class 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 - 2024 Weber Informatics LLC | Privacy Policy