
com.britesnow.snow.util.AnnotationMap Maven / Gradle / Ivy
package com.britesnow.snow.util;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* An AnnotationMap build a Map of Annotation by their Class name, and expose a Generic base get(annotationClass) to get the instance.
*
* @author jeremychone
*
*/
public class AnnotationMap {
Map, Annotation> annotationDic = new HashMap, Annotation>();
public AnnotationMap(Annotation[] annotations){
if (annotations != null){
for (Annotation an : annotations){
annotationDic.put(an.annotationType(),an);
}
}
}
public AnnotationMap(List annotations){
if (annotations != null){
for (Annotation an : annotations){
annotationDic.put(an.getClass(),an);
}
}
}
public T get(Class annotationClass){
return (T) annotationDic.get(annotationClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy