use of javaslang.match.annotation.Patterns in project javaslang by javaslang.
the class PatternsProcessor method transform.
// Verify correct usage of annotations @Patterns and @Unapply
private Set<ClassModel> transform(Set<TypeElement> typeElements) {
final Set<ClassModel> classModels = new HashSet<>();
final javax.lang.model.util.Elements elementUtils = processingEnv.getElementUtils();
final Messager messager = processingEnv.getMessager();
for (TypeElement typeElement : typeElements) {
final ClassModel classModel = ClassModel.of(elementUtils, typeElement);
final List<MethodModel> methodModels = classModel.getMethods().stream().filter(method -> method.isAnnotatedWith(Unapply.class)).collect(toList());
if (methodModels.isEmpty()) {
messager.printMessage(Diagnostic.Kind.WARNING, "No @Unapply methods found.", classModel.typeElement());
} else {
final boolean methodsValid = methodModels.stream().reduce(true, (bool, method) -> bool && UnapplyChecker.isValid(method.getExecutableElement(), messager), (b1, b2) -> b1 && b2);
if (methodsValid) {
classModels.add(classModel);
}
}
}
return classModels;
}
Aggregations