Skip to content

Commit

Permalink
Half-recursive getProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Sep 7, 2023
1 parent d25c76d commit 66064be
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,28 +750,30 @@ private static ConfigMappingInterface[] getSuperTypes(Class<?>[] interfaces, int
}

static Property[] getProperties(Method[] methods, int si, int ti) {
if (si == methods.length) {
if (ti == 0) {
return NO_PROPERTIES;
for (int i = si; i < methods.length; i++) {
Method method = methods[i];
int mods = method.getModifiers();
if (!Modifier.isPublic(mods) || Modifier.isStatic(mods) || !Modifier.isAbstract(mods)) {
// no need for recursive calls here, which are costy in interpreted mode!
continue;
}
if (method.getParameterCount() > 0) {
throw new IllegalArgumentException("Configuration methods cannot accept parameters");
}
if (method.getReturnType() == void.class) {
throw new IllegalArgumentException("Void config methods are not allowed");
}
Property p = getPropertyDef(method, method.getAnnotatedReturnType());
final Property[] array;
if (i + 1 == methods.length) {
array = new Property[ti + 1];
} else {
return new Property[ti];
array = getProperties(methods, i + 1, ti + 1);
}
array[ti] = p;
return array;
}
Method method = methods[si];
int mods = method.getModifiers();
if (!Modifier.isPublic(mods) || Modifier.isStatic(mods) || !Modifier.isAbstract(mods)) {
return getProperties(methods, si + 1, ti);
}
if (method.getParameterCount() > 0) {
throw new IllegalArgumentException("Configuration methods cannot accept parameters");
}
if (method.getReturnType() == void.class) {
throw new IllegalArgumentException("Void config methods are not allowed");
}
Property p = getPropertyDef(method, method.getAnnotatedReturnType());
Property[] array = getProperties(methods, si + 1, ti + 1);
array[ti] = p;
return array;
return NO_PROPERTIES;
}

private static Property getPropertyDef(Method method, AnnotatedType type) {
Expand Down

0 comments on commit 66064be

Please sign in to comment.