You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Drop 'expectedType' parameter from #getClass and #getEnum methods and
rely on compiler inference based on type of assigned variable, e.g.
public @interface Example {
Color color();
Class<? extends UserType> userType();
int order() default 0;
}
AnnotationAttributes example =
AnnotationUtils.getAnnotationAttributes(Example.class, true, true);
Color color = example.getEnum("color");
Class<? extends UserType> userType = example.getClass("userType");
or in cases where there is no variable assignment (and thus no
inference possible), use explicit generic type, e.g.
bean.setColor(example.<Color>getEnum("color"));
- Rename #get{Int=>Number} and update return type from int to
<N extends Number>, allowing invocations such as:
int order = example.getNumber("order");
These changes reduce the overall number of methods exposed by
AnnotationAttributes, while at the same time providing comprehensive
access to all possible annotation attribute types -- that is, instead of
requiring explicit #getInt, #getFloat, #getDouble methods, the
single #getNumber method is capabable of handling them all, and without
any casting required. And the obvious additional benefit is more concise
invocation as no redundant 'expectedType' parameters are required.
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/cache/annotation/ProxyCachingConfiguration.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor() {
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java
+1-2
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,7 @@ public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
73
73
"@%s is not present on importing class '%s' as expected",
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java
+6-6
Original file line number
Diff line number
Diff line change
@@ -70,15 +70,15 @@ public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan) {
70
70
Assert.notNull(this.resourceLoader, "ResourceLoader must not be null");
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java
Copy file name to clipboardexpand all lines: org.springframework.context/src/main/java/org/springframework/scheduling/annotation/ProxyAsyncConfiguration.java
+2-3
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
Copy file name to clipboardexpand all lines: org.springframework.transaction/src/main/java/org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
0 commit comments