From 7766b518d31c72279f4076fff9d1914df4a1f7e0 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 5 Mar 2023 15:51:50 +0100 Subject: [PATCH] Apply "instanceof pattern matching" in spring-context-indexer module See gh-30067 --- .../context/index/processor/CandidateComponentsIndexer.java | 6 +++--- .../springframework/context/index/processor/TypeHelper.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java b/spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java index 9f1edf7f0cc..d9a1fa5af60 100644 --- a/spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java +++ b/spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -133,8 +133,8 @@ public class CandidateComponentsIndexer implements Processor { List list = new ArrayList<>(); for (Element element : elements) { if ((element.getKind().isClass() || element.getKind() == ElementKind.INTERFACE) && - element.getModifiers().contains(Modifier.STATIC) && element instanceof TypeElement) { - list.add((TypeElement) element); + element.getModifiers().contains(Modifier.STATIC) && element instanceof TypeElement te) { + list.add(te); } } return list; diff --git a/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java b/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java index 11400ae00dc..a3418e05700 100644 --- a/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java +++ b/spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,8 +73,8 @@ class TypeHelper { } private String getQualifiedName(Element element) { - if (element instanceof QualifiedNameable) { - return ((QualifiedNameable) element).getQualifiedName().toString(); + if (element instanceof QualifiedNameable qualifiedNameable) { + return qualifiedNameable.getQualifiedName().toString(); } return element.toString(); }