Skip to content

Commit 156546a

Browse files
committed
Make AnnotationAttributes.validated field immutable
1 parent 1a05ba3 commit 156546a

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
5353

5454
final String displayName;
5555

56-
boolean validated = false;
56+
final boolean validated;
5757

5858

5959
/**
@@ -62,6 +62,7 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
6262
public AnnotationAttributes() {
6363
this.annotationType = null;
6464
this.displayName = UNKNOWN;
65+
this.validated = false;
6566
}
6667

6768
/**
@@ -73,6 +74,7 @@ public AnnotationAttributes(int initialCapacity) {
7374
super(initialCapacity);
7475
this.annotationType = null;
7576
this.displayName = UNKNOWN;
77+
this.validated = false;
7678
}
7779

7880
/**
@@ -85,6 +87,7 @@ public AnnotationAttributes(Map<String, Object> map) {
8587
super(map);
8688
this.annotationType = null;
8789
this.displayName = UNKNOWN;
90+
this.validated = false;
8891
}
8992

9093
/**
@@ -108,9 +111,20 @@ public AnnotationAttributes(AnnotationAttributes other) {
108111
* @since 4.2
109112
*/
110113
public AnnotationAttributes(Class<? extends Annotation> annotationType) {
111-
Assert.notNull(annotationType, "'annotationType' must not be null");
112-
this.annotationType = annotationType;
113-
this.displayName = annotationType.getName();
114+
this(annotationType, false);
115+
}
116+
117+
/**
118+
* Create a new, empty {@link AnnotationAttributes} instance for the
119+
* specified {@code annotationType}.
120+
* @param annotationType the annotation type name represented by this
121+
* {@code AnnotationAttributes} instance; never {@code null}
122+
* @param classLoader the ClassLoader to try to load the annotation type on,
123+
* or {@code null} to just store the annotation type name
124+
* @since 4.3.2
125+
*/
126+
public AnnotationAttributes(String annotationType, @Nullable ClassLoader classLoader) {
127+
this(getAnnotationType(annotationType, classLoader), false);
114128
}
115129

116130
/**
@@ -129,20 +143,6 @@ public AnnotationAttributes(Class<? extends Annotation> annotationType) {
129143
this.validated = validated;
130144
}
131145

132-
/**
133-
* Create a new, empty {@link AnnotationAttributes} instance for the
134-
* specified {@code annotationType}.
135-
* @param annotationType the annotation type name represented by this
136-
* {@code AnnotationAttributes} instance; never {@code null}
137-
* @param classLoader the ClassLoader to try to load the annotation type on,
138-
* or {@code null} to just store the annotation type name
139-
* @since 4.3.2
140-
*/
141-
public AnnotationAttributes(String annotationType, @Nullable ClassLoader classLoader) {
142-
Assert.notNull(annotationType, "'annotationType' must not be null");
143-
this.annotationType = getAnnotationType(annotationType, classLoader);
144-
this.displayName = annotationType;
145-
}
146146

147147
@SuppressWarnings("unchecked")
148148
@Nullable

0 commit comments

Comments
 (0)