List of usage examples for javax.lang.model.element TypeElement getAnnotationsByType
<A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);
From source file:org.lambdamatic.mongodb.apt.template.MetadataTemplateContext.java
/** * Full constructor/*from w ww. j a v a 2s . co m*/ * * @param domainElement the {@link TypeElement} to work on. * @param templateFieldBuildFunction the {@link Function} used to generate a single * {@link TemplateField} from a given relevant {@link VariableElement} in the given * {@link TypeElement}. * @param templateMethodsBuildFunction the {@link Function} used to generate zero or more * {@link TemplateMethods} from a given relevant {@link VariableElement} in the given * {@link TypeElement}. * */ private MetadataTemplateContext(final TypeElement domainElement, final BaseAnnotationProcessor annotationProcessor, final BiFunction<VariableElement, ProcessingEnvironment, TemplateField> templateFieldBuildFunction, final Function<DeclaredType, String> simpleClassNameBuilder, final String templateFileName) { super((DeclaredType) domainElement.asType(), annotationProcessor); this.domainTypeFields = domainElement.getEnclosedElements().stream() .filter(e -> e.getKind() == ElementKind.FIELD) .filter(e -> e.getAnnotation(TransientField.class) == null).map(e -> (VariableElement) e) .collect(Collectors.toList()); this.templateFields = this.domainTypeFields.stream().map(f -> { return templateFieldBuildFunction.apply(f, annotationProcessor.getProcessingEnvironment()); }).collect(Collectors.toList()); this.simpleClassName = simpleClassNameBuilder.apply(this.domainType); this.fullyQualifiedClassName = getPackageName() + '.' + this.simpleClassName; this.templateFileName = templateFileName; this.annotations = Stream.of(domainElement.getAnnotationsByType(EmbeddedDocument.class)) .map(a -> TemplateAnnotation.Builder.type(EmbeddedDocument.class).build()) .collect(Collectors.toList()); }