mirror of
https://github.com/lightbend/config.git
synced 2025-02-22 01:00:31 +08:00
remove withFallbacks() convenience method
since withFallback() now works properly, it's easy to do things without withFallbacks().
This commit is contained in:
parent
4b9e5ec325
commit
7df8e342f6
@ -56,9 +56,6 @@ public interface Config extends ConfigMergeable {
|
||||
@Override
|
||||
Config withFallback(ConfigMergeable other);
|
||||
|
||||
@Override
|
||||
Config withFallbacks(ConfigMergeable... others);
|
||||
|
||||
@Override
|
||||
ConfigObject toValue();
|
||||
|
||||
|
@ -77,7 +77,7 @@ public final class ConfigFactory {
|
||||
Config referenceFiles = parseResourcesForPath(rootPath + ".reference",
|
||||
options);
|
||||
|
||||
return system.withFallbacks(mainFiles, referenceFiles);
|
||||
return system.withFallback(mainFiles).withFallback(referenceFiles);
|
||||
}
|
||||
|
||||
public static ConfigRoot emptyRoot(String rootPath) {
|
||||
|
@ -38,14 +38,4 @@ public interface ConfigMergeable {
|
||||
* used)
|
||||
*/
|
||||
ConfigMergeable withFallback(ConfigMergeable other);
|
||||
|
||||
/**
|
||||
* Convenience method just calls withFallback() on each of the values;
|
||||
* earlier values in the list win over later ones. The semantics of merging
|
||||
* are described in https://github.com/havocp/config/blob/master/HOCON.md
|
||||
*
|
||||
* @param fallbacks
|
||||
* @return a version of the object with the requested fallbacks merged in
|
||||
*/
|
||||
ConfigMergeable withFallbacks(ConfigMergeable... others);
|
||||
}
|
||||
|
@ -61,9 +61,6 @@ public interface ConfigObject extends ConfigValue, Map<String, ConfigValue> {
|
||||
@Override
|
||||
ConfigObject withFallback(ConfigMergeable other);
|
||||
|
||||
@Override
|
||||
ConfigObject withFallbacks(ConfigMergeable... others);
|
||||
|
||||
/**
|
||||
* Gets a ConfigValue at the given key, or returns null if there is no
|
||||
* value. The returned ConfigValue may have ConfigValueType.NULL or any
|
||||
|
@ -24,9 +24,6 @@ public interface ConfigRoot extends Config {
|
||||
@Override
|
||||
ConfigRoot withFallback(ConfigMergeable fallback);
|
||||
|
||||
@Override
|
||||
ConfigRoot withFallbacks(ConfigMergeable... fallbacks);
|
||||
|
||||
/**
|
||||
* Gets the global app name that this root represents.
|
||||
*
|
||||
|
@ -32,7 +32,4 @@ public interface ConfigValue extends ConfigMergeable {
|
||||
|
||||
@Override
|
||||
ConfigValue withFallback(ConfigMergeable other);
|
||||
|
||||
@Override
|
||||
ConfigValue withFallbacks(ConfigMergeable... fallbacks);
|
||||
}
|
||||
|
@ -105,11 +105,6 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
protected abstract AbstractConfigObject newCopy(ResolveStatus status,
|
||||
boolean ignoresFallbacks);
|
||||
|
||||
@Override
|
||||
public AbstractConfigObject withFallbacks(ConfigMergeable... others) {
|
||||
return (AbstractConfigObject) super.withFallbacks(others);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractConfigObject withFallback(ConfigMergeable mergeable) {
|
||||
ConfigValue other = mergeable.toValue();
|
||||
|
@ -87,14 +87,6 @@ abstract class AbstractConfigValue implements ConfigValue {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractConfigValue withFallbacks(ConfigMergeable... fallbacks) {
|
||||
// note: this is a no-op unless the subclass overrides withFallback().
|
||||
// But we need to do this because subclass withFallback() may not
|
||||
// just "return this"
|
||||
return ConfigImpl.merge(AbstractConfigValue.class, this, fallbacks);
|
||||
}
|
||||
|
||||
protected boolean canEqual(Object other) {
|
||||
return other instanceof ConfigValue;
|
||||
}
|
||||
|
@ -112,11 +112,6 @@ class ConfigDelayedMergeObject extends AbstractConfigObject implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigDelayedMergeObject withFallbacks(ConfigMergeable... others) {
|
||||
return (ConfigDelayedMergeObject) super.withFallbacks(others);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AbstractConfigValue> unmergedValues() {
|
||||
return stack;
|
||||
|
@ -45,12 +45,6 @@ final class RootConfig extends SimpleConfig implements ConfigRoot {
|
||||
return super.withFallback(value).asRoot(rootPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootConfig withFallbacks(ConfigMergeable... values) {
|
||||
// this can return "this" if the withFallbacks does nothing
|
||||
return super.withFallbacks(values).asRoot(rootPath);
|
||||
}
|
||||
|
||||
Path rootPathObject() {
|
||||
return rootPath;
|
||||
}
|
||||
|
@ -388,13 +388,6 @@ class SimpleConfig implements Config {
|
||||
return object.withFallback(other).toConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleConfig withFallbacks(ConfigMergeable... others) {
|
||||
// this can return "this" if the withFallbacks doesn't need a new
|
||||
// ConfigObject
|
||||
return object.withFallbacks(others).toConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object other) {
|
||||
if (other instanceof SimpleConfig) {
|
||||
|
@ -31,10 +31,7 @@ class ConfigTest extends TestUtils {
|
||||
if (toMerge.isEmpty) {
|
||||
SimpleConfigObject.empty()
|
||||
} else {
|
||||
val obj = toMerge(0).withFallbacks(toMerge.slice(1, toMerge.size): _*)
|
||||
obj match {
|
||||
case x: AbstractConfigObject => x
|
||||
}
|
||||
toMerge.reduce((first, second) => first.withFallback(second))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user