List of usage examples for java.lang Class isAnnotation
public boolean isAnnotation()
From source file:org.seedstack.seed.core.utils.BaseClassSpecifications.java
/** * Checks if the class is an annotation// ww w. java2s . co m * * @return the specification */ public static Specification<Class<?>> classIsAnnotation() { return new AbstractSpecification<Class<?>>() { @Override public boolean isSatisfiedBy(Class<?> candidate) { return candidate != null && candidate.isAnnotation(); } }; }
From source file:org.unitils.mock.core.proxy.CloneUtil.java
/** * @param instanceToClone The instance, not null * @return True if the instance is immutable, e.g. a primitive *//*from w ww .ja v a 2 s .co m*/ protected static boolean isImmutable(Object instanceToClone) { Class<?> clazz = instanceToClone.getClass(); if (clazz.isPrimitive() || clazz.isEnum() || clazz.isAnnotation()) { return true; } if (instanceToClone instanceof Number || instanceToClone instanceof String || instanceToClone instanceof Character || instanceToClone instanceof Boolean) { return true; } if (clazz.getName().startsWith("com.google.common.collect") && clazz.getName().contains("Immutable")) { return true; } return false; }
From source file:org.wso2.carbon.tomcat.internal.SCIRegistrarContextConfig.java
@Override protected void processServletContainerInitializers(ServletContext servletContext) { //Scan JARs for ServletContainerInitializer implementations. // Code below is from {@link org.apache.catalina.startup.ContextConfig} List<ServletContainerInitializer> detectedScis; try {/* w ww .ja v a2 s . c om*/ WebappServiceLoader<ServletContainerInitializer> loader = new WebappServiceLoader<ServletContainerInitializer>( servletContext, context.getContainerSciFilter()); detectedScis = loader.load(ServletContainerInitializer.class); } catch (IOException e) { log.error(sm.getString("contextConfig.servletContainerInitializerFail", context.getName()), e);//prints the full stack trace ok = false; return; } //code belongs to org.wso2.carbon.tomcat.internal.SCIRegistrarContextConfig List<ServletContainerInitializer> mutableDetectedScis = getCustomSciList(detectedScis); // Code below is from {@link org.apache.catalina.startup.ContextConfig} //made changes in logging. for (ServletContainerInitializer sci : mutableDetectedScis) { initializerClassMap.put(sci, new HashSet<Class<?>>()); HandlesTypes ht; try { ht = sci.getClass().getAnnotation(HandlesTypes.class); } catch (Exception e) {//class defined in the @HandlesTypes annotation can be missing.Can throw // NullPointerException. if (log.isDebugEnabled()) { log.debug(sm.getString("contextConfig.sci.debug", sci.getClass().getName()), e);//changed log.info to log.debug.The debug level prints the full stack trace. } else { log.info(sm.getString("contextConfig.sci.info", sci.getClass().getName())); } continue; } if (ht == null) { continue; } Class<?>[] types = ht.value(); if (types == null) { continue; } for (Class<?> type : types) { if (type.isAnnotation()) { handlesTypesAnnotations = true; } else { handlesTypesNonAnnotations = true; } Set<ServletContainerInitializer> scis = typeInitializerMap.get(type); if (scis == null) { scis = new HashSet<ServletContainerInitializer>(); typeInitializerMap.put(type, scis); } scis.add(sci); } } }