diff options
| author | Kostya <mail@sartin.in> | 2026-07-22 21:54:28 +0000 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-07-22 21:54:28 +0000 |
| commit | 2f4cc7c66c41defc04641f0ad0a056e5baf9f618 (patch) | |
| tree | 53c35f6daf37d838478c1a0a2bff4adfbbf88440 /ex1/src/main/java | |
| parent | c60b6979d8a90b3af03ed94034277e45271383a1 (diff) | |
| download | java-course-2f4cc7c66c41defc04641f0ad0a056e5baf9f618.tar.gz java-course-2f4cc7c66c41defc04641f0ad0a056e5baf9f618.tar.xz java-course-2f4cc7c66c41defc04641f0ad0a056e5baf9f618.zip | |
whoops
Diffstat (limited to 'ex1/src/main/java')
| -rw-r--r-- | ex1/src/main/java/reflection/api/ReflectionInvestigator.java | 10 |
1 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 | } |