use of org.springframework.boot.SpringBootVersion in project sofa-ark by alipay.
the class OnSpringBootVersion method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
Map<String, Object> springBootVersion = metadata.getAnnotationAttributes(ConditionalOnSpringBootVersion.class.getCanonicalName());
if (springBootVersion == null || springBootVersion.get("version") == null) {
return new ConditionOutcome(false, "No specified spring boot version.");
}
ConditionalOnSpringBootVersion.Version version = (ConditionalOnSpringBootVersion.Version) springBootVersion.get("version");
if (ConditionalOnSpringBootVersion.Version.ANY.equals(version)) {
return new ConditionOutcome(true, "Conditional on Any Spring Boot.");
} else if (ConditionalOnSpringBootVersion.Version.OneX.equals(version)) {
if (SpringBootVersion.getVersion().startsWith("1")) {
return new ConditionOutcome(true, "Conditional on OneX Spring Boot.");
} else {
return new ConditionOutcome(false, "Conditional on OneX Spring Boot.");
}
} else if (ConditionalOnSpringBootVersion.Version.TwoX.equals(version)) {
if (SpringBootVersion.getVersion().startsWith("2")) {
return new ConditionOutcome(true, "Conditional on TwoX Spring Boot.");
} else {
return new ConditionOutcome(false, "Conditional on TwoX Spring Boot.");
}
}
throw new IllegalStateException("Error Spring Boot Version.");
}
Aggregations