remove withFallbacks() convenience method

since withFallback() now works properly, it's easy
to do things without withFallbacks().
This commit is contained in:
Havoc Pennington 2011-11-18 15:16:40 -05:00
parent 4b9e5ec325
commit 7df8e342f6
12 changed files with 2 additions and 58 deletions

View File

@ -56,9 +56,6 @@ public interface Config extends ConfigMergeable {
@Override @Override
Config withFallback(ConfigMergeable other); Config withFallback(ConfigMergeable other);
@Override
Config withFallbacks(ConfigMergeable... others);
@Override @Override
ConfigObject toValue(); ConfigObject toValue();

View File

@ -77,7 +77,7 @@ public final class ConfigFactory {
Config referenceFiles = parseResourcesForPath(rootPath + ".reference", Config referenceFiles = parseResourcesForPath(rootPath + ".reference",
options); options);
return system.withFallbacks(mainFiles, referenceFiles); return system.withFallback(mainFiles).withFallback(referenceFiles);
} }
public static ConfigRoot emptyRoot(String rootPath) { public static ConfigRoot emptyRoot(String rootPath) {

View File

@ -38,14 +38,4 @@ public interface ConfigMergeable {
* used) * used)
*/ */
ConfigMergeable withFallback(ConfigMergeable other); 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);
} }

View File

@ -61,9 +61,6 @@ public interface ConfigObject extends ConfigValue, Map<String, ConfigValue> {
@Override @Override
ConfigObject withFallback(ConfigMergeable other); ConfigObject withFallback(ConfigMergeable other);
@Override
ConfigObject withFallbacks(ConfigMergeable... others);
/** /**
* Gets a ConfigValue at the given key, or returns null if there is no * Gets a ConfigValue at the given key, or returns null if there is no
* value. The returned ConfigValue may have ConfigValueType.NULL or any * value. The returned ConfigValue may have ConfigValueType.NULL or any

View File

@ -24,9 +24,6 @@ public interface ConfigRoot extends Config {
@Override @Override
ConfigRoot withFallback(ConfigMergeable fallback); ConfigRoot withFallback(ConfigMergeable fallback);
@Override
ConfigRoot withFallbacks(ConfigMergeable... fallbacks);
/** /**
* Gets the global app name that this root represents. * Gets the global app name that this root represents.
* *

View File

@ -32,7 +32,4 @@ public interface ConfigValue extends ConfigMergeable {
@Override @Override
ConfigValue withFallback(ConfigMergeable other); ConfigValue withFallback(ConfigMergeable other);
@Override
ConfigValue withFallbacks(ConfigMergeable... fallbacks);
} }

View File

@ -105,11 +105,6 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
protected abstract AbstractConfigObject newCopy(ResolveStatus status, protected abstract AbstractConfigObject newCopy(ResolveStatus status,
boolean ignoresFallbacks); boolean ignoresFallbacks);
@Override
public AbstractConfigObject withFallbacks(ConfigMergeable... others) {
return (AbstractConfigObject) super.withFallbacks(others);
}
@Override @Override
public AbstractConfigObject withFallback(ConfigMergeable mergeable) { public AbstractConfigObject withFallback(ConfigMergeable mergeable) {
ConfigValue other = mergeable.toValue(); ConfigValue other = mergeable.toValue();

View File

@ -87,14 +87,6 @@ abstract class AbstractConfigValue implements ConfigValue {
return this; 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) { protected boolean canEqual(Object other) {
return other instanceof ConfigValue; return other instanceof ConfigValue;
} }

View File

@ -112,11 +112,6 @@ class ConfigDelayedMergeObject extends AbstractConfigObject implements
} }
} }
@Override
public ConfigDelayedMergeObject withFallbacks(ConfigMergeable... others) {
return (ConfigDelayedMergeObject) super.withFallbacks(others);
}
@Override @Override
public Collection<AbstractConfigValue> unmergedValues() { public Collection<AbstractConfigValue> unmergedValues() {
return stack; return stack;

View File

@ -45,12 +45,6 @@ final class RootConfig extends SimpleConfig implements ConfigRoot {
return super.withFallback(value).asRoot(rootPath); 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() { Path rootPathObject() {
return rootPath; return rootPath;
} }

View File

@ -388,13 +388,6 @@ class SimpleConfig implements Config {
return object.withFallback(other).toConfig(); 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 @Override
public final boolean equals(Object other) { public final boolean equals(Object other) {
if (other instanceof SimpleConfig) { if (other instanceof SimpleConfig) {

View File

@ -31,10 +31,7 @@ class ConfigTest extends TestUtils {
if (toMerge.isEmpty) { if (toMerge.isEmpty) {
SimpleConfigObject.empty() SimpleConfigObject.empty()
} else { } else {
val obj = toMerge(0).withFallbacks(toMerge.slice(1, toMerge.size): _*) toMerge.reduce((first, second) => first.withFallback(second))
obj match {
case x: AbstractConfigObject => x
}
} }
} }