Class ClassAnnotationUtil
- java.lang.Object
 - 
- org.silverpeas.core.util.annotation.ClassAnnotationUtil
 
 
- 
public class ClassAnnotationUtil extends Object
- Author:
 - Yohann Chastagnier
 
 
- 
- 
Constructor Summary
Constructors Constructor Description ClassAnnotationUtil() 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Class<T>searchClassThatDeclaresAnnotation(Class<? extends Annotation> searchedAnnotationClass, Class<?> fromClass)This method is awesome.static <T> Class<T>searchParameterizedTypeFrom(Class<?> searchedParametrizedTypeClass, Class<?> fromClass)This method is awesome. 
 - 
 
- 
- 
Method Detail
- 
searchParameterizedTypeFrom
public static <T> Class<T> searchParameterizedTypeFrom(Class<?> searchedParametrizedTypeClass, Class<?> fromClass)
This method is awesome. It permits to retrieve the class of a parametrized type, even if this type is parametrized into a super class or interface from a hierarchy of classes.Example (it is stupid, but it is for understanding):
When trying to get some parametrized type information from an instance of Wikispeed, perform this operation:public interface Car<? extends Model, ? extends Engine> {...} public abstract SedanElectricCar extends Car<Sedan, Electric> {...} public class Wikispeed implements SedanElectricCar {...}
Some explanations:Class<? extends Engine> engineClassOfCar = AnnotationUtil.searchParameterizedTypeFrom(Engine.class, Wikispeed.class)- Engine.class is the superclass of the searched class from parametrized type
 - Wikispeed.class is the instance from which the parametrized type is searched
 
- Type Parameters:
 T- the class type.- Parameters:
 searchedParametrizedTypeClass- the superclass of the searched parametrized type.fromClass- the instance from which the parametrized type is searched.- Returns:
 - the class of the parametrized type if any, null otherwise.
 
 
- 
searchClassThatDeclaresAnnotation
public static <T> Class<T> searchClassThatDeclaresAnnotation(Class<? extends Annotation> searchedAnnotationClass, Class<?> fromClass)
This method is awesome. It permits to retrieve the class from a class hierarchy the one that declares the given annotation.- Type Parameters:
 T- the class type.- Parameters:
 searchedAnnotationClass- the class of the searched annotation.fromClass- the class from which the annotation is searched.- Returns:
 - the class that declares the given annotation, null otherwise.
 
 
 - 
 
 -