Skip to content

Commit e462c8d

Browse files
committed
recursively inspect superclasses
1 parent 2d33d2f commit e462c8d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name=OneConfig
33
mod_id=oneconfig
44
version_major=1
55
version_minor=0
6-
version_patch=0-alpha.37
6+
version_patch=0-alpha.38
77

88
polyfrost.defaults.loom=3
99

modules/config-impl/src/main/java/org/polyfrost/oneconfig/api/config/v1/collect/impl/ReflectiveCollector.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,29 @@ public ReflectiveCollector(int maxDepth) {
6060

6161

6262
public void handle(@NotNull Tree tree, @NotNull Object src, int depth) {
63-
for (Field f : src.getClass().getDeclaredFields()) {
63+
Class<?> cls = src.getClass();
64+
for (Field f : cls.getDeclaredFields()) {
6465
handleField(f, src, tree);
6566
}
66-
for (Method m : src.getClass().getDeclaredMethods()) {
67+
for (Method m : cls.getDeclaredMethods()) {
6768
handleMethod(m, src, tree);
6869
}
69-
Class<?> superClass = src.getClass().getSuperclass();
70-
if (superClass != null) {
70+
Class<?> superClass = cls.getSuperclass();
71+
while (superClass != null) {
7172
for (Field f : superClass.getDeclaredFields()) {
7273
handleField(f, src, tree);
7374
}
7475
for (Method m : superClass.getDeclaredMethods()) {
7576
handleMethod(m, src, tree);
7677
}
78+
superClass = superClass.getSuperclass();
7779
}
78-
for (Class<?> c : src.getClass().getDeclaredClasses()) {
80+
for (Class<?> sub : cls.getDeclaredClasses()) {
7981
if (depth >= maxDepth) {
8082
LOGGER.warn("Reached max depth for tree {} ignoring further subclasses!", tree.getID());
8183
return;
8284
}
83-
handleInnerClass(c, src, depth + 1, tree);
85+
handleInnerClass(sub, src, depth + 1, tree);
8486
}
8587
}
8688
}

0 commit comments

Comments
 (0)