Polishing
This commit is contained in:
@@ -295,7 +295,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Specify the set of profiles to be made active by default if no other profiles
|
||||
* are explicitly made active through {@link #setActiveProfiles}.
|
||||
* <p>Calling this method removes overrides any reserved default profiles
|
||||
* that may have been added during construction of the environment.
|
||||
* @see #AbstractEnvironment()
|
||||
@@ -455,6 +456,51 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
// Implementation of ConfigurablePropertyResolver interface
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public ConfigurableConversionService getConversionService() {
|
||||
return this.propertyResolver.getConversionService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConversionService(ConfigurableConversionService conversionService) {
|
||||
this.propertyResolver.setConversionService(conversionService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholderPrefix(String placeholderPrefix) {
|
||||
this.propertyResolver.setPlaceholderPrefix(placeholderPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholderSuffix(String placeholderSuffix) {
|
||||
this.propertyResolver.setPlaceholderSuffix(placeholderSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
this.propertyResolver.setValueSeparator(valueSeparator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) {
|
||||
this.propertyResolver.setIgnoreUnresolvableNestedPlaceholders(ignoreUnresolvableNestedPlaceholders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequiredProperties(String... requiredProperties) {
|
||||
this.propertyResolver.setRequiredProperties(requiredProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateRequiredProperties() throws MissingRequiredPropertiesException {
|
||||
this.propertyResolver.validateRequiredProperties();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Implementation of PropertyResolver interface
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean containsProperty(String key) {
|
||||
return this.propertyResolver.containsProperty(key);
|
||||
@@ -495,16 +541,6 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
return this.propertyResolver.getRequiredProperty(key, targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequiredProperties(String... requiredProperties) {
|
||||
this.propertyResolver.setRequiredProperties(requiredProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateRequiredProperties() throws MissingRequiredPropertiesException {
|
||||
this.propertyResolver.validateRequiredProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolvePlaceholders(String text) {
|
||||
return this.propertyResolver.resolvePlaceholders(text);
|
||||
@@ -515,36 +551,6 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
return this.propertyResolver.resolveRequiredPlaceholders(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) {
|
||||
this.propertyResolver.setIgnoreUnresolvableNestedPlaceholders(ignoreUnresolvableNestedPlaceholders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConversionService(ConfigurableConversionService conversionService) {
|
||||
this.propertyResolver.setConversionService(conversionService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurableConversionService getConversionService() {
|
||||
return this.propertyResolver.getConversionService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholderPrefix(String placeholderPrefix) {
|
||||
this.propertyResolver.setPlaceholderPrefix(placeholderPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholderSuffix(String placeholderSuffix) {
|
||||
this.propertyResolver.setPlaceholderSuffix(placeholderSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
this.propertyResolver.setValueSeparator(valueSeparator);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -65,16 +65,50 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the prefix that placeholders replaced by this resolver must begin with.
|
||||
* <p>The default is "${".
|
||||
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_PREFIX
|
||||
*/
|
||||
@Override
|
||||
public String getProperty(String key, String defaultValue) {
|
||||
String value = getProperty(key);
|
||||
return (value != null ? value : defaultValue);
|
||||
public void setPlaceholderPrefix(String placeholderPrefix) {
|
||||
this.placeholderPrefix = placeholderPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the suffix that placeholders replaced by this resolver must end with.
|
||||
* <p>The default is "}".
|
||||
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX
|
||||
*/
|
||||
@Override
|
||||
public <T> T getProperty(String key, Class<T> targetType, T defaultValue) {
|
||||
T value = getProperty(key, targetType);
|
||||
return (value != null ? value : defaultValue);
|
||||
public void setPlaceholderSuffix(String placeholderSuffix) {
|
||||
this.placeholderSuffix = placeholderSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the separating character between the placeholders replaced by this
|
||||
* resolver and their associated default value, or {@code null} if no such
|
||||
* special character should be processed as a value separator.
|
||||
* <p>The default is ":".
|
||||
* @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR
|
||||
*/
|
||||
@Override
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
this.valueSeparator = valueSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to throw an exception when encountering an unresolvable placeholder
|
||||
* nested within the value of a given property. A {@code false} value indicates strict
|
||||
* resolution, i.e. that an exception will be thrown. A {@code true} value indicates
|
||||
* that unresolvable nested placeholders should be passed through in their unresolved
|
||||
* ${...} form.
|
||||
* <p>The default is {@code false}.
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) {
|
||||
this.ignoreUnresolvableNestedPlaceholders = ignoreUnresolvableNestedPlaceholders;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,6 +131,19 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProperty(String key, String defaultValue) {
|
||||
String value = getProperty(key);
|
||||
return (value != null ? value : defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getProperty(String key, Class<T> targetType, T defaultValue) {
|
||||
T value = getProperty(key, targetType);
|
||||
return (value != null ? value : defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredProperty(String key) throws IllegalStateException {
|
||||
String value = getProperty(key);
|
||||
@@ -115,33 +162,6 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} The default is "${".
|
||||
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_PREFIX
|
||||
*/
|
||||
@Override
|
||||
public void setPlaceholderPrefix(String placeholderPrefix) {
|
||||
this.placeholderPrefix = placeholderPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} The default is "}".
|
||||
* @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX
|
||||
*/
|
||||
@Override
|
||||
public void setPlaceholderSuffix(String placeholderSuffix) {
|
||||
this.placeholderSuffix = placeholderSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} The default is ":".
|
||||
* @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR
|
||||
*/
|
||||
@Override
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
this.valueSeparator = valueSeparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolvePlaceholders(String text) {
|
||||
if (this.nonStrictHelper == null) {
|
||||
@@ -158,16 +178,6 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||
return doResolvePlaceholders(text, this.strictHelper);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>The default value for this implementation is {@code false}.
|
||||
* @since 3.2
|
||||
*/
|
||||
@Override
|
||||
public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) {
|
||||
this.ignoreUnresolvableNestedPlaceholders = ignoreUnresolvableNestedPlaceholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve placeholders within the given string, deferring to the value of
|
||||
* {@link #setIgnoreUnresolvableNestedPlaceholders} to determine whether any
|
||||
@@ -199,6 +209,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the specified property as a raw String,
|
||||
* i.e. without resolution of nested placeholders.
|
||||
|
||||
@@ -223,8 +223,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this {@code PropertySource} contains a property with the given name.
|
||||
* <p>This implementation first checks to see if the name specified is the special
|
||||
* This implementation first checks to see if the name specified is the special
|
||||
* {@linkplain #setNonOptionArgsPropertyName(String) "non-option arguments" property},
|
||||
* and if so delegates to the abstract {@link #getNonOptionArgs()} method
|
||||
* checking to see whether it returns an empty collection. Otherwise delegates to and
|
||||
@@ -239,8 +238,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>This implementation first checks to see if the name specified is the special
|
||||
* This implementation first checks to see if the name specified is the special
|
||||
* {@linkplain #setNonOptionArgsPropertyName(String) "non-option arguments" property},
|
||||
* and if so delegates to the abstract {@link #getNonOptionArgs()} method. If so
|
||||
* and the collection of non-option arguments is empty, this method returns {@code
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,6 +73,19 @@ public interface ConfigurablePropertyResolver extends PropertyResolver {
|
||||
*/
|
||||
void setValueSeparator(String valueSeparator);
|
||||
|
||||
/**
|
||||
* Set whether to throw an exception when encountering an unresolvable placeholder
|
||||
* nested within the value of a given property. A {@code false} value indicates strict
|
||||
* resolution, i.e. that an exception will be thrown. A {@code true} value indicates
|
||||
* that unresolvable nested placeholders should be passed through in their unresolved
|
||||
* ${...} form.
|
||||
* <p>Implementations of {@link #getProperty(String)} and its variants must inspect
|
||||
* the value set here to determine correct behavior when property values contain
|
||||
* unresolvable placeholders.
|
||||
* @since 3.2
|
||||
*/
|
||||
void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders);
|
||||
|
||||
/**
|
||||
* Specify which properties must be present, to be verified by
|
||||
* {@link #validateRequiredProperties()}.
|
||||
@@ -88,16 +101,4 @@ public interface ConfigurablePropertyResolver extends PropertyResolver {
|
||||
*/
|
||||
void validateRequiredProperties() throws MissingRequiredPropertiesException;
|
||||
|
||||
/**
|
||||
* Set whether to throw an exception when encountering an unresolvable placeholder
|
||||
* nested within the value of a given property. A {@code false} value indicates strict
|
||||
* resolution, i.e. that an exception will be thrown. A {@code true} value indicates
|
||||
* that unresolvable nested placeholders should be passed through in their unresolved
|
||||
* ${...} form.
|
||||
* <p>Implementations of {@link #getProperty(String)} and its variants must inspect
|
||||
* the value set here to determine correct behavior when property values contain
|
||||
* unresolvable placeholders.
|
||||
* @since 3.2
|
||||
*/
|
||||
void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user