Implement containsProperty on MapPropertySource
Improve the performance of MapPropertySource by directly implementing the containsProperty property. Issue: SPR-12224
This commit is contained in:
parent
2077388f38
commit
e71fbb9f46
|
@ -18,6 +18,7 @@ package org.springframework.core.env;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,4 +44,15 @@ public class MapPropertySource extends EnumerablePropertySource<Map<String, Obje
|
||||||
return StringUtils.toStringArray(this.source.keySet());
|
return StringUtils.toStringArray(this.source.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsProperty(String name) {
|
||||||
|
Assert.notNull(name, "Property name must not be null");
|
||||||
|
boolean containsProperty = this.source.containsKey(name);
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(String.format("PropertySource [%s] %s '%s'", getName(),
|
||||||
|
(containsProperty ? "contains" : "does not contain"), name));
|
||||||
|
}
|
||||||
|
return containsProperty;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue