use of javaslang.match.model.MethodModel in project javaslang by javaslang.
the class Generator method generate.
// Expands the @Unapply methods of a @Patterns class
private static String generate(ImportManager im, ClassModel classModel, List<MethodModel> methodModels) {
final StringBuilder builder = new StringBuilder();
for (MethodModel methodModel : methodModels) {
generate(im, classModel, methodModel, builder);
builder.append("\n");
}
return builder.toString();
}
use of javaslang.match.model.MethodModel 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