List of usage examples for java.lang.reflect AnnotatedElement isAnnotationPresent
default boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
From source file:org.castor.cpa.jpa.processors.fieldprocessors.JPAVersionProcessor.java
private <A> boolean verifyArguments(final A annotation, final AnnotatedElement target) { if (!(annotation instanceof Version) || (!target.isAnnotationPresent(Version.class))) { return false; }/* w ww . j av a2 s.c o m*/ return true; }
From source file:org.compass.annotations.config.binding.AnnotationsMappingBinding.java
private boolean processNonSearchableAnnotations(AnnotatedElement annotatedElement) { boolean found = false; if (annotatedElement.isAnnotationPresent(SearchConverter.class)) { found = true;/*w w w . j a v a 2 s . c o m*/ bindConverter(annotatedElement.getAnnotation(SearchConverter.class)); } if (annotatedElement.isAnnotationPresent(SearchConverters.class)) { found = true; SearchConverters searchConverters = annotatedElement.getAnnotation(SearchConverters.class); for (SearchConverter searchConverter : searchConverters.value()) { bindConverter(searchConverter); } } if (annotatedElement.isAnnotationPresent(SearchAnalyzer.class)) { found = true; bindAnalyzer(annotatedElement.getAnnotation(SearchAnalyzer.class)); } if (annotatedElement.isAnnotationPresent(SearchAnalyzers.class)) { found = true; SearchAnalyzers searchAnalyzers = annotatedElement.getAnnotation(SearchAnalyzers.class); for (SearchAnalyzer searchAnalyzer : searchAnalyzers.value()) { bindAnalyzer(searchAnalyzer); } } if (annotatedElement.isAnnotationPresent(SearchAnalyzerFilter.class)) { found = true; bindAnalyzerFilter(annotatedElement.getAnnotation(SearchAnalyzerFilter.class)); } if (annotatedElement.isAnnotationPresent(SearchAnalyzerFilters.class)) { found = true; SearchAnalyzerFilters searchAnalyzerFilters = annotatedElement .getAnnotation(SearchAnalyzerFilters.class); for (SearchAnalyzerFilter searchAnalyzerFilter : searchAnalyzerFilters.value()) { bindAnalyzerFilter(searchAnalyzerFilter); } } return found; }
From source file:org.compass.annotations.config.binding.AnnotationsMappingBinding.java
private void processsAnnotatedElement(Class<?> searchableClass, String name, String accessor, Class<?> clazz, Type type, Annotation annotation, AnnotatedElement annotatedElement) { if (annotation instanceof SearchableId) { ClassIdPropertyMapping classPropertyMapping = new ClassIdPropertyMapping(); SearchableId searchableId = (SearchableId) annotation; bindObjectMapping(classPropertyMapping, accessor, name, searchableId.accessor(), searchableClass); bindClassPropertyIdMapping(searchableId, classPropertyMapping, clazz, type, annotatedElement); classMapping.addMapping(classPropertyMapping); } else if (annotation instanceof SearchableIdComponent) { IdComponentMapping componentMapping = new IdComponentMapping(); SearchableIdComponent searchableComponent = (SearchableIdComponent) annotation; bindObjectMapping(componentMapping, accessor, name, searchableComponent.accessor(), searchableClass); bindComponent(searchableComponent, componentMapping, clazz, type); classMapping.addMapping(componentMapping); } else if (annotation instanceof SearchableProperty) { ClassPropertyMapping classPropertyMapping = new ClassPropertyMapping(); SearchableProperty searchableProperty = (SearchableProperty) annotation; bindObjectMapping(classPropertyMapping, accessor, name, searchableProperty.accessor(), searchableClass); bindClassPropertyMapping(searchableProperty, classPropertyMapping, annotatedElement, clazz, type); classMapping.addMapping(classPropertyMapping); } else if (annotation instanceof SearchableDynamicProperty) { ClassDynamicPropertyMapping dynamicPropertyMapping = new ClassDynamicPropertyMapping(); SearchableDynamicProperty searchableDynamicProperty = (SearchableDynamicProperty) annotation; bindObjectMapping(dynamicPropertyMapping, accessor, name, searchableDynamicProperty.accessor(), searchableClass);/*from ww w .jav a 2 s . com*/ bindClassDynamicPropertyMapping(searchableDynamicProperty, dynamicPropertyMapping, annotatedElement, clazz, type); classMapping.addMapping(dynamicPropertyMapping); } else if (annotation instanceof SearchableComponent) { ComponentMapping componentMapping = new ComponentMapping(); SearchableComponent searchableComponent = (SearchableComponent) annotation; bindObjectMapping(componentMapping, accessor, name, searchableComponent.accessor(), searchableClass); bindComponent(searchableComponent, componentMapping, clazz, type); classMapping.addMapping(componentMapping); } else if (annotation instanceof SearchableReference) { ReferenceMapping referenceMapping = new ReferenceMapping(); SearchableReference searchableReference = (SearchableReference) annotation; bindObjectMapping(referenceMapping, accessor, name, searchableReference.accessor(), searchableClass); bindReference(searchableReference, referenceMapping, clazz, type); classMapping.addMapping(referenceMapping); } else if (annotation instanceof SearchableAnalyzerProperty) { ClassPropertyAnalyzerController analyzerMapping = new ClassPropertyAnalyzerController(); SearchableAnalyzerProperty searchableAnalyzerProperty = (SearchableAnalyzerProperty) annotation; bindObjectMapping(analyzerMapping, accessor, name, searchableAnalyzerProperty.accessor(), searchableClass); bindAnalyzer(searchableAnalyzerProperty, analyzerMapping, clazz, type); classMapping.addMapping(analyzerMapping); } else if (annotation instanceof SearchableBoostProperty) { ClassBoostPropertyMapping boostPropertyMapping = new ClassBoostPropertyMapping(); SearchableBoostProperty searchableBoostProperty = (SearchableBoostProperty) annotation; bindObjectMapping(boostPropertyMapping, accessor, name, searchableBoostProperty.accessor(), searchableClass); bindBoost(searchableBoostProperty, boostPropertyMapping, clazz, type); classMapping.addMapping(boostPropertyMapping); } else if (annotation instanceof SearchableParent) { ParentMapping parentMapping = new ParentMapping(); SearchableParent searchableParent = (SearchableParent) annotation; bindObjectMapping(parentMapping, accessor, name, searchableParent.accessor(), searchableClass); bindParent(searchableParent, parentMapping, clazz, type); classMapping.addMapping(parentMapping); } else if (annotation instanceof SearchableCascading) { PlainCascadeMapping cascadeMapping = new PlainCascadeMapping(); SearchableCascading searchableCascading = (SearchableCascading) annotation; bindObjectMapping(cascadeMapping, accessor, name, searchableCascading.accessor(), searchableClass); bindCascade(searchableCascading, cascadeMapping, clazz, type); classMapping.addMapping(cascadeMapping); } else if ((annotation instanceof SearchableMetaData) || (annotation instanceof SearchableMetaDatas)) { if (!annotatedElement.isAnnotationPresent(SearchableProperty.class) && !annotatedElement.isAnnotationPresent(SearchableId.class)) { throw new MappingException( "SearchableMetaData/s annotation exists without a SearchableProperty/Id, it will be ignored"); } } }
From source file:org.jspare.forvertx.web.collector.HandlerCollector.java
@SuppressWarnings("unchecked") private static List<Annotation> getHttpMethodsPresents(AnnotatedElement element) { List<Class<?>> filteredClazz = new ArrayList<>(); filteredClazz.addAll(Arrays.asList(HttpMethodType.values()).stream().map(ht -> ht.getHttpMethodClass()) .collect(Collectors.toList())); filteredClazz.removeIf(clazzHttpMethodType -> !element .isAnnotationPresent((Class<? extends Annotation>) clazzHttpMethodType)); return filteredClazz.stream() .map(httpMethodClazz -> element.getAnnotation((Class<? extends Annotation>) httpMethodClazz)) .collect(Collectors.toList()); }