List of usage examples for java.lang Class isAnnotationPresent
@Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
From source file:com.darkstar.beanCartography.utils.NameUtils.java
/** * @param clazz class to check/*w w w . ja va 2s .c o m*/ * @return <code>true</code> if the class has a composite annotation */ public static boolean hasBusinessComposites(Class<?> clazz) { Preconditions.checkNotNull(clazz, "Class cannot be null"); return clazz.isAnnotationPresent(NamedClassComposite.class); }
From source file:net.ymate.platform.core.beans.intercept.InterceptAnnoHelper.java
public static List<Class<? extends IInterceptor>> getBeforeIntercepts(Class<?> targetClass, Method targetMethod) {//from ww w. j a v a 2s . c o m List<Class<? extends IInterceptor>> _classes = new ArrayList<Class<? extends IInterceptor>>(); if (targetClass.isAnnotationPresent(Before.class)) { Before _before = targetClass.getAnnotation(Before.class); Clean _clean = getCleanIntercepts(targetMethod); // if (_clean != null && (_clean.type().equals(IInterceptor.CleanType.ALL) || _clean.type().equals(IInterceptor.CleanType.BEFORE))) { if (_clean.value().length > 0) { for (Class<? extends IInterceptor> _clazz : _before.value()) { if (ArrayUtils.contains(_clean.value(), _clazz)) { continue; } _classes.add(_clazz); } } } else { Collections.addAll(_classes, _before.value()); } } // if (targetMethod.isAnnotationPresent(Before.class)) { Collections.addAll(_classes, targetMethod.getAnnotation(Before.class).value()); } // return _classes; }
From source file:net.ymate.platform.core.beans.intercept.InterceptAnnoHelper.java
public static List<Class<? extends IInterceptor>> getAfterIntercepts(Class<?> targetClass, Method targetMethod) {//from ww w.j a va 2 s . c o m List<Class<? extends IInterceptor>> _classes = new ArrayList<Class<? extends IInterceptor>>(); if (targetClass.isAnnotationPresent(After.class)) { After _after = targetClass.getAnnotation(After.class); Clean _clean = getCleanIntercepts(targetMethod); // if (_clean != null && (_clean.type().equals(IInterceptor.CleanType.ALL) || _clean.type().equals(IInterceptor.CleanType.AFTER))) { if (_clean.value().length > 0) { for (Class<? extends IInterceptor> _clazz : _after.value()) { if (ArrayUtils.contains(_clean.value(), _clazz)) { continue; } _classes.add(_clazz); } } } else { Collections.addAll(_classes, _after.value()); } } // if (targetMethod.isAnnotationPresent(After.class)) { Collections.addAll(_classes, targetMethod.getAnnotation(After.class).value()); } // return _classes; }
From source file:de.taimos.dvalin.interconnect.core.spring.test.InterconnectRequestMock.java
private static String getQueueName(final Class<?>[] interfaces) { for (final Class<?> iface : interfaces) { if (iface.isAnnotationPresent(Daemon.class)) { return iface.getAnnotation(Daemon.class).name() + ".request"; }//w w w .j a v a 2s . co m } throw new RuntimeException("No @Daemon annotation found"); }
From source file:com.meiah.core.util.ReflectionUtils.java
/** * ?//from ww w .j av a 2 s . c o m * @param className className ?? com.meiah.app.entity.portal.Module * @return * @author "zhangshaofeng" * @time Jun 10, 2012 2:44:51 PM */ @SuppressWarnings("unchecked") public static String getClassDesc(String className) { try { Class model = Class.forName(className); if (model.isAnnotationPresent(Description.class)) { String description = model.getAnnotation(Description.class).toString(); description = description.split("name=")[1]; description = description.substring(0, description.lastIndexOf(")")); return description; } else { return className; } } catch (Exception e) { logger.error("?", e); } return null; }
From source file:edu.stanford.epad.common.plugins.impl.ClassFinderTestUtils.java
public static boolean isPluginHandler(Class<?> testClass) { return testClass.isAnnotationPresent(PluginHandler.class); }
From source file:com.qmetry.qaf.automation.step.JavaStepFinder.java
private static Set<Method> getAllMethodsWithAnnotation(Collection<Class<?>> classes, Class<? extends Annotation> annotation) { Set<Method> methods = new HashSet<Method>(); for (Class<?> cls : classes) { if (cls.isInterface() || Modifier.isAbstract(cls.getModifiers())) continue; boolean isStepProvider = cls.isAnnotationPresent(QAFTestStepProvider.class); for (Method method : cls.getMethods()) { if (isStepProvider || ClassUtil.hasAnnotation(method, annotation)) { methods.add(method);//from w ww . ja va 2 s.co m } } } return methods; }
From source file:org.apache.metron.common.dsl.functions.resolver.BaseFunctionResolver.java
/** * Resolves a Stellar function from a given class. * @param clazz The class.//from ww w.j a va 2 s.com */ public static StellarFunctionInfo resolveFunction(Class<? extends StellarFunction> clazz) { StellarFunctionInfo info = null; // the class must be annotated if (clazz.isAnnotationPresent(Stellar.class)) { Stellar annotation = clazz.getAnnotation(Stellar.class); String fullyQualifiedName = getNameFromAnnotation(annotation); StellarFunction function = createFunction(clazz); if (fullyQualifiedName != null && function != null) { info = new StellarFunctionInfo(annotation.description(), fullyQualifiedName, annotation.params(), annotation.returns(), function); } } return info; }
From source file:org.keycloak.testsuite.arquillian.AppServerTestEnricher.java
/** * * @param testClass//from ww w . j a va 2 s . c om * @param annotationClass * @return testClass or the nearest superclass of testClass annotated with * annotationClass */ public static Class getNearestSuperclassWithAppServerAnnotation(Class<?> testClass) { return (testClass.isAnnotationPresent(AppServerContainer.class) || testClass.isAnnotationPresent(AppServerContainers.class)) ? testClass : (testClass.getSuperclass().equals(Object.class) ? null // stop recursion : getNearestSuperclassWithAppServerAnnotation(testClass.getSuperclass())); // continue recursion }
From source file:org.diorite.impl.connection.packets.Packet.java
public static PacketClass getPacketData(@SuppressWarnings("rawtypes") final Class<? extends Packet> clazz) { PacketClass pc = map.get(clazz.getSimpleName()); if (pc == null) { synchronized (map) { if (!clazz.isAnnotationPresent(PacketClass.class)) { throw new IllegalArgumentException( "To use this method, class must be annotated with PacketClass"); }/*from ww w. j a v a2 s. c om*/ pc = clazz.getAnnotation(PacketClass.class); map.put(clazz.getSimpleName(), pc); } } return pc; }