Browse Source

Implement containsProperty on MapPropertySource

Improve the performance of MapPropertySource by directly implementing
the containsProperty property.

Issue: SPR-12224
pull/648/head
Phillip Webb 11 years ago
parent
commit
e71fbb9f46
  1. 12
      spring-core/src/main/java/org/springframework/core/env/MapPropertySource.java

12
spring-core/src/main/java/org/springframework/core/env/MapPropertySource.java vendored

@ -18,6 +18,7 @@ package org.springframework.core.env; @@ -18,6 +18,7 @@ package org.springframework.core.env;
import java.util.Map;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
@ -43,4 +44,15 @@ public class MapPropertySource extends EnumerablePropertySource<Map<String, Obje @@ -43,4 +44,15 @@ public class MapPropertySource extends EnumerablePropertySource<Map<String, Obje
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…
Cancel
Save