Skip to content
Snippets Groups Projects

3.0.1

Merged René Schöne requested to merge dev into main
35 files
+ 1103
1487
Compare changes
  • Side-by-side
  • Inline

Files

@@ -48,29 +48,28 @@ aspect ClassAnalysis {
String tokenName = invokeName(annotation);
if (tokenName.startsWith("_impl_")) {
String relationName = titleCase(tokenName.substring(6));
try {
java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName);
if (present(getMethod(clazz, "get" + relationName), relationMethod -> {
// normal get + token-name -> singleRelation
SingleRelationMethod singleRelationMethod = new SingleRelationMethod();
SingleRelationMethod singleRelationMethod = getMethod(clazz, "has" + relationName).isPresent() ?
new OptRelationMethod() : new SingleRelationMethod();
singleRelationMethod.setMethod(relationMethod);
singleRelationMethod.setName(relationName);
result.addOtherMethod(singleRelationMethod);
})) {
continue;
} catch (NoSuchMethodException e) {
// ignore, but we know this is probably not a single relation
}
// we know here this is probably not a single or opt relation
// try list-relation next
try {
java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName + "List");
if (present(getMethod(clazz, "get" + relationName + "List"), relationMethod -> {
// normal get + token-name + "List" -> listRelation
ListRelationMethod listRelationMethod = new ListRelationMethod();
listRelationMethod.setMethod(relationMethod);
listRelationMethod.setName(relationName);
result.addOtherMethod(listRelationMethod);
})) {
continue;
} catch (NoSuchMethodException e) {
// ignore, but we know this is probably not a relation at all
}
// we know here this is probably not a relation at all
}
IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod();
tokenMethod.setMethod(method);
@@ -201,6 +200,20 @@ aspect ClassAnalysis {
}
}
private static java.util.Optional<java.lang.reflect.Method> DumpAst.getMethod(Class<?> clazz, String methodName) {
try {
java.lang.reflect.Method method = clazz.getMethod(methodName);
return java.util.Optional.of(method);
} catch (NoSuchMethodException e) {
return java.util.Optional.empty();
}
}
private static <T> boolean DumpAst.present(java.util.Optional<T> optional, java.util.function.Consumer<T> callback) {
optional.ifPresent(callback);
return optional.isPresent();
}
// --- astNodeAnnotationPrefix ---
syn String DumpAst.astNodeAnnotationPrefix() = getPackageName() + ".ASTNodeAnnotation";
inh String DumpNode.astNodeAnnotationPrefix();
Loading