Apply "instanceof pattern matching"

This commit is contained in:
Sam Brannen
2022-11-29 17:56:54 +01:00
parent a88dbbec98
commit fdec9f0adc
6 changed files with 33 additions and 34 deletions

View File

@@ -108,14 +108,14 @@ public class PropertySourceProcessor {
// We've already added a version, we need to extend it
org.springframework.core.env.PropertySource<?> existing = propertySources.get(name);
if (existing != null) {
PropertySource<?> newSource = (propertySource instanceof ResourcePropertySource ?
((ResourcePropertySource) propertySource).withResourceName() : propertySource);
if (existing instanceof CompositePropertySource) {
((CompositePropertySource) existing).addFirstPropertySource(newSource);
PropertySource<?> newSource = (propertySource instanceof ResourcePropertySource rps ?
rps.withResourceName() : propertySource);
if (existing instanceof CompositePropertySource cps) {
cps.addFirstPropertySource(newSource);
}
else {
if (existing instanceof ResourcePropertySource) {
existing = ((ResourcePropertySource) existing).withResourceName();
if (existing instanceof ResourcePropertySource rps) {
existing = rps.withResourceName();
}
CompositePropertySource composite = new CompositePropertySource(name);
composite.addPropertySource(newSource);