Java examples for java.lang.annotation:Annotation Parameter
Creates proxy (implementation) for given annotation type with given parameters.
import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; public class Main{ /**//from w w w . j av a2 s.co m * Creates proxy (implementation) for given annotation type with given parameters. * * @param annotation the annotation type for which will be created proxy. * @param parameters the parameters (values) of annotation members. * @return The proxy (implementation) of given annotation type. */ @SuppressWarnings("unchecked") public static <T extends Annotation> T getAnnotationProxy( Class<T> annotation, Map<String, Object> parameters) { Preconditions.checkArgument(annotation != null, "Annotation cannot be null"); AnnotationProxy proxy = new AnnotationProxy(annotation, parameters); return (T) Proxy.newProxyInstance(annotation.getClassLoader(), new Class<?>[] { annotation, Annotation.class }, proxy); } }