Skip to content

Commit 9a9130b

Browse files
committed
Use pattern matching for the instanceof operator
I had missed one, and reworded the example in the Journal.
1 parent 504e69c commit 9a9130b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/com/jeantessier/classreader/MetricsGatherer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ public void visitDeprecated_attribute(Deprecated_attribute attribute) {
529529

530530
Object owner = attribute.getOwner();
531531

532-
if (owner instanceof Classfile) {
533-
deprecatedClasses.add((Classfile) owner);
534-
} else if (owner instanceof Field_info) {
535-
deprecatedFields.add((Field_info) owner);
536-
} else if (owner instanceof Method_info) {
537-
deprecatedMethods.add((Method_info) owner);
532+
if (owner instanceof Classfile classfile) {
533+
deprecatedClasses.add(classfile);
534+
} else if (owner instanceof Field_info field) {
535+
deprecatedFields.add(field);
536+
} else if (owner instanceof Method_info method) {
537+
deprecatedMethods.add(method);
538538
} else {
539539
Logger.getLogger(getClass()).warn("Deprecated attribute on unknown Visitable: " + owner.getClass().getName());
540540
}

0 commit comments

Comments
 (0)