Skip to content

Commit 810220e

Browse files
committed
Use ANNOTATION_TYPE in OnPropertyPrefixCondition
Add a static ANNOTATION_TYPE constant for ConditionalOnPropertyPrefix and use it when reading annotation attributes and creating ResolvablePlaceholderAnnotationAttributes. This replaces direct references to ConditionalOnPropertyPrefix.class/its name, reducing duplication and improving maintainability.
1 parent 90ab736 commit 810220e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

microsphere-spring-boot-core/src/main/java/io/microsphere/spring/boot/condition/OnPropertyPrefixCondition.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
*/
4343
class OnPropertyPrefixCondition extends SpringBootCondition {
4444

45+
static final Class<ConditionalOnPropertyPrefix> ANNOTATION_TYPE = ConditionalOnPropertyPrefix.class;
46+
4547
/**
4648
* Evaluates whether properties with the specified prefix exist in the {@link ConfigurableEnvironment}.
4749
* Returns a match if at least one property name starts with any of the configured prefix values.
@@ -63,11 +65,11 @@ class OnPropertyPrefixCondition extends SpringBootCondition {
6365
@Override
6466
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
6567

66-
AnnotationAttributes annotationAttributes = fromMap(metadata.getAnnotationAttributes(ConditionalOnPropertyPrefix.class.getName()));
68+
AnnotationAttributes annotationAttributes = fromMap(metadata.getAnnotationAttributes(ANNOTATION_TYPE.getName()));
6769

6870
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
6971

70-
ResolvablePlaceholderAnnotationAttributes attributes = of(annotationAttributes, environment);
72+
ResolvablePlaceholderAnnotationAttributes attributes = of(annotationAttributes, ANNOTATION_TYPE, environment);
7173

7274
String[] prefixValues = attributes.getStringArray("value");
7375

0 commit comments

Comments
 (0)