diff options
Diffstat (limited to 'ex1')
| -rw-r--r-- | ex1/src/main/java/reflection/api/ReflectionInvestigator.java | 10 | ||||
| -rw-r--r-- | ex1/target/classes/reflection/api/ReflectionInvestigator.class | bin | 7051 -> 7016 bytes |
2 files changed, 4 insertions, 6 deletions
diff --git a/ex1/src/main/java/reflection/api/ReflectionInvestigator.java b/ex1/src/main/java/reflection/api/ReflectionInvestigator.java index e16d3d5..16fafc1 100644 --- a/ex1/src/main/java/reflection/api/ReflectionInvestigator.java +++ b/ex1/src/main/java/reflection/api/ReflectionInvestigator.java | |||
| @@ -78,9 +78,7 @@ public class ReflectionInvestigator implements Investigator { | |||
| 78 | var cursor = classInfo; | 78 | var cursor = classInfo; |
| 79 | while (cursor != null) { | 79 | while (cursor != null) { |
| 80 | fields.addAll( | 80 | fields.addAll( |
| 81 | Stream.of(classInfo.getDeclaredFields()) | 81 | Stream.of(cursor.getDeclaredFields()).map(f -> f.getName()).collect(Collectors.toSet())); |
| 82 | .map(f -> f.getName()) | ||
| 83 | .collect(Collectors.toSet())); | ||
| 84 | cursor = cursor.getSuperclass(); | 82 | cursor = cursor.getSuperclass(); |
| 85 | } | 83 | } |
| 86 | return fields; | 84 | return fields; |
| @@ -127,12 +125,12 @@ public class ReflectionInvestigator implements Investigator { | |||
| 127 | @Override | 125 | @Override |
| 128 | public String getInheritanceChain(String delimiter) { | 126 | public String getInheritanceChain(String delimiter) { |
| 129 | var nameStack = new HashSet<String>(); | 127 | var nameStack = new HashSet<String>(); |
| 130 | nameStack.add(classInfo.getSimpleName()); | ||
| 131 | var cursor = classInfo; | 128 | var cursor = classInfo; |
| 132 | while (cursor != null) { | 129 | do { |
| 133 | nameStack.add(cursor.getSimpleName()); | 130 | nameStack.add(cursor.getSimpleName()); |
| 134 | cursor = cursor.getSuperclass(); | 131 | cursor = cursor.getSuperclass(); |
| 135 | } | 132 | } while (cursor != null); |
| 133 | |||
| 136 | return String.join(" >> ", nameStack); | 134 | return String.join(" >> ", nameStack); |
| 137 | } | 135 | } |
| 138 | } | 136 | } |
diff --git a/ex1/target/classes/reflection/api/ReflectionInvestigator.class b/ex1/target/classes/reflection/api/ReflectionInvestigator.class index 18a2f21..4d75e52 100644 --- a/ex1/target/classes/reflection/api/ReflectionInvestigator.class +++ b/ex1/target/classes/reflection/api/ReflectionInvestigator.class | |||
| Binary files differ | |||