diff --git a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java index aab74aeecb..07bf83141e 100644 --- a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java @@ -60,7 +60,9 @@ public interface AnnotatedTypeMetadata { * {@code null} if no matching annotation is defined. */ @Nullable - Map getAnnotationAttributes(String annotationName); + default Map getAnnotationAttributes(String annotationName) { + return getAnnotationAttributes(annotationName, false); + } /** * Retrieve the attributes of the annotation of the given type, if any (i.e. if @@ -90,7 +92,9 @@ public interface AnnotatedTypeMetadata { * @see #getAllAnnotationAttributes(String, boolean) */ @Nullable - MultiValueMap getAllAnnotationAttributes(String annotationName); + default MultiValueMap getAllAnnotationAttributes(String annotationName) { + return getAllAnnotationAttributes(annotationName, false); + } /** * Retrieve all attributes of all annotations of the given type, if any (i.e. if diff --git a/spring-core/src/main/java/org/springframework/core/type/AnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/AnnotationMetadata.java index b644a1d439..f2d4ebac89 100644 --- a/spring-core/src/main/java/org/springframework/core/type/AnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/AnnotationMetadata.java @@ -56,7 +56,9 @@ public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata * type to look for * @return {@code true} if a matching annotation is present */ - boolean hasAnnotation(String annotationName); + default boolean hasAnnotation(String annotationName) { + return getAnnotationTypes().contains(annotationName); + } /** * Determine whether the underlying class has an annotation that is itself diff --git a/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java b/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java index 4b70d0f739..adb685324b 100644 --- a/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java @@ -55,7 +55,9 @@ public interface ClassMetadata { * Return whether the underlying class represents a concrete class, * i.e. neither an interface nor an abstract class. */ - boolean isConcrete(); + default boolean isConcrete() { + return !(isInterface() || isAbstract()); + } /** * Return whether the underlying class is marked as 'final'. @@ -76,7 +78,9 @@ public interface ClassMetadata { *

If this method returns {@code false}, then the underlying * class is a top-level class. */ - boolean hasEnclosingClass(); + default boolean hasEnclosingClass() { + return (getEnclosingClassName() != null); + } /** * Return the name of the enclosing class of the underlying class, @@ -88,7 +92,9 @@ public interface ClassMetadata { /** * Return whether the underlying class has a super class. */ - boolean hasSuperClass(); + default boolean hasSuperClass() { + return (getSuperClassName() != null); + } /** * Return the name of the super class of the underlying class, diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java index b4ffd55a51..27c00023fa 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java @@ -123,11 +123,6 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements AnnotatedElementUtils.isAnnotated(getIntrospectedClass(), annotationName)); } - @Override - public Map getAnnotationAttributes(String annotationName) { - return getAnnotationAttributes(annotationName, false); - } - @Override @Nullable public Map getAnnotationAttributes(String annotationName, boolean classValuesAsString) { @@ -135,12 +130,6 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements getIntrospectedClass(), annotationName, classValuesAsString, this.nestedAnnotationsAsMap) : null); } - @Override - @Nullable - public MultiValueMap getAllAnnotationAttributes(String annotationName) { - return getAllAnnotationAttributes(annotationName, false); - } - @Override @Nullable public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java index 7e3042d5f3..0b4fe333de 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java @@ -72,11 +72,6 @@ public class StandardClassMetadata implements ClassMetadata { return Modifier.isAbstract(this.introspectedClass.getModifiers()); } - @Override - public boolean isConcrete() { - return !(isInterface() || isAbstract()); - } - @Override public boolean isFinal() { return Modifier.isFinal(this.introspectedClass.getModifiers()); @@ -89,11 +84,6 @@ public class StandardClassMetadata implements ClassMetadata { Modifier.isStatic(this.introspectedClass.getModifiers()))); } - @Override - public boolean hasEnclosingClass() { - return (this.introspectedClass.getEnclosingClass() != null); - } - @Override @Nullable public String getEnclosingClassName() { @@ -101,11 +91,6 @@ public class StandardClassMetadata implements ClassMetadata { return (enclosingClass != null ? enclosingClass.getName() : null); } - @Override - public boolean hasSuperClass() { - return (this.introspectedClass.getSuperclass() != null); - } - @Override @Nullable public String getSuperClassName() { diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java index e7fd449699..854aff0293 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java @@ -115,12 +115,6 @@ public class StandardMethodMetadata implements MethodMetadata { return AnnotatedElementUtils.isAnnotated(this.introspectedMethod, annotationName); } - @Override - @Nullable - public Map getAnnotationAttributes(String annotationName) { - return getAnnotationAttributes(annotationName, false); - } - @Override @Nullable public Map getAnnotationAttributes(String annotationName, boolean classValuesAsString) { @@ -128,12 +122,6 @@ public class StandardMethodMetadata implements MethodMetadata { annotationName, classValuesAsString, this.nestedAnnotationsAsMap); } - @Override - @Nullable - public MultiValueMap getAllAnnotationAttributes(String annotationName) { - return getAllAnnotationAttributes(annotationName, false); - } - @Override @Nullable public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java index a32628088d..bb342a512c 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java @@ -109,14 +109,6 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito return (metaAnnotationTypes != null ? metaAnnotationTypes : Collections.emptySet()); } - @Override - public boolean hasAnnotation(String annotationName) { - if (AnnotationUtils.isInJavaLangAnnotationPackage(annotationName)) { - return false; - } - return this.annotationSet.contains(annotationName); - } - @Override public boolean hasMetaAnnotation(String metaAnnotationType) { if (AnnotationUtils.isInJavaLangAnnotationPackage(metaAnnotationType)) { @@ -137,12 +129,6 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito this.attributesMap.containsKey(annotationName)); } - @Override - @Nullable - public AnnotationAttributes getAnnotationAttributes(String annotationName) { - return getAnnotationAttributes(annotationName, false); - } - @Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) { @@ -155,12 +141,6 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString); } - @Override - @Nullable - public MultiValueMap getAllAnnotationAttributes(String annotationName) { - return getAllAnnotationAttributes(annotationName, false); - } - @Override @Nullable public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java index 2e4c745ecf..e9d760ef7f 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java @@ -165,11 +165,6 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata return this.isAbstract; } - @Override - public boolean isConcrete() { - return !(this.isInterface || this.isAbstract); - } - @Override public boolean isFinal() { return this.isFinal; @@ -191,11 +186,6 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata return this.enclosingClassName; } - @Override - public boolean hasSuperClass() { - return (this.superClassName != null); - } - @Override @Nullable public String getSuperClassName() { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java index a0e681577e..1e1f0faee7 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java @@ -119,12 +119,6 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho return this.attributesMap.containsKey(annotationName); } - @Override - @Nullable - public AnnotationAttributes getAnnotationAttributes(String annotationName) { - return getAnnotationAttributes(annotationName, false); - } - @Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) { @@ -137,12 +131,6 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho "method '" + getMethodName() + "'", this.classLoader, raw, classValuesAsString); } - @Override - @Nullable - public MultiValueMap getAllAnnotationAttributes(String annotationName) { - return getAllAnnotationAttributes(annotationName, false); - } - @Override @Nullable public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {