diff --git a/src/main/java/com/typesafe/config/impl/AbstractConfigObject.java b/src/main/java/com/typesafe/config/impl/AbstractConfigObject.java index 9c351c39..06213e09 100644 --- a/src/main/java/com/typesafe/config/impl/AbstractConfigObject.java +++ b/src/main/java/com/typesafe/config/impl/AbstractConfigObject.java @@ -189,10 +189,10 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements @Override public AbstractConfigObject withFallback(ConfigValue other) { - if (other instanceof Unresolved) { + if (other instanceof Unmergeable) { List stack = new ArrayList(); stack.add(this); - stack.addAll(((Unresolved) other).unmergedValues()); + stack.addAll(((Unmergeable) other).unmergedValues()); return new ConfigDelayedMergeObject(mergeOrigins(stack), stack); } else if (other instanceof AbstractConfigObject) { AbstractConfigObject fallback = (AbstractConfigObject) other; diff --git a/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java b/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java index 04c48e8d..64b56beb 100644 --- a/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java +++ b/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java @@ -18,7 +18,7 @@ import com.typesafe.config.ConfigValueType; * substitutions. */ final class ConfigDelayedMerge extends AbstractConfigValue implements - Unresolved { + Unmergeable { // earlier items in the stack win final private List stack; @@ -88,13 +88,13 @@ final class ConfigDelayedMerge extends AbstractConfigValue implements @Override public AbstractConfigValue withFallback(ConfigValue other) { if (other instanceof AbstractConfigObject - || other instanceof Unresolved) { + || other instanceof Unmergeable) { // if we turn out to be an object, and the fallback also does, // then a merge may be required; delay until we resolve. List newStack = new ArrayList(); newStack.addAll(stack); - if (other instanceof Unresolved) - newStack.addAll(((Unresolved) other).unmergedValues()); + if (other instanceof Unmergeable) + newStack.addAll(((Unmergeable) other).unmergedValues()); else newStack.add((AbstractConfigValue) other); return new ConfigDelayedMerge( diff --git a/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java b/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java index b3d98fd6..3e355fbf 100644 --- a/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java +++ b/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java @@ -14,7 +14,7 @@ import com.typesafe.config.ConfigValue; // This is just like ConfigDelayedMerge except we know statically // that it will turn out to be an object. class ConfigDelayedMergeObject extends AbstractConfigObject implements - Unresolved { + Unmergeable { final private List stack; @@ -85,13 +85,13 @@ class ConfigDelayedMergeObject extends AbstractConfigObject implements @Override public ConfigDelayedMergeObject withFallback(ConfigValue other) { if (other instanceof AbstractConfigObject - || other instanceof Unresolved) { + || other instanceof Unmergeable) { // since we are an object, and the fallback could be, // then a merge may be required; delay until we resolve. List newStack = new ArrayList(); newStack.addAll(stack); - if (other instanceof Unresolved) - newStack.addAll(((Unresolved) other).unmergedValues()); + if (other instanceof Unmergeable) + newStack.addAll(((Unmergeable) other).unmergedValues()); else newStack.add((AbstractConfigValue) other); return new ConfigDelayedMergeObject( diff --git a/src/main/java/com/typesafe/config/impl/ConfigSubstitution.java b/src/main/java/com/typesafe/config/impl/ConfigSubstitution.java index a70774a3..a1d74829 100644 --- a/src/main/java/com/typesafe/config/impl/ConfigSubstitution.java +++ b/src/main/java/com/typesafe/config/impl/ConfigSubstitution.java @@ -16,7 +16,7 @@ import com.typesafe.config.ConfigValueType; * than one piece it always resolves to a string via value concatenation. */ final class ConfigSubstitution extends AbstractConfigValue implements - Unresolved { + Unmergeable { // this is a list of String and Path where the Path // have to be resolved to values, then if there's more @@ -44,13 +44,13 @@ final class ConfigSubstitution extends AbstractConfigValue implements @Override public AbstractConfigValue withFallback(ConfigValue other) { if (other instanceof AbstractConfigObject - || other instanceof Unresolved) { + || other instanceof Unmergeable) { // if we turn out to be an object, and the fallback also does, // then a merge may be required; delay until we resolve. List newStack = new ArrayList(); newStack.add(this); - if (other instanceof Unresolved) - newStack.addAll(((Unresolved) other).unmergedValues()); + if (other instanceof Unmergeable) + newStack.addAll(((Unmergeable) other).unmergedValues()); else newStack.add((AbstractConfigValue) other); return new ConfigDelayedMerge( diff --git a/src/main/java/com/typesafe/config/impl/Unmergeable.java b/src/main/java/com/typesafe/config/impl/Unmergeable.java new file mode 100644 index 00000000..82dc203e --- /dev/null +++ b/src/main/java/com/typesafe/config/impl/Unmergeable.java @@ -0,0 +1,13 @@ +package com.typesafe.config.impl; + +import java.util.Collection; + +/** + * Interface that tags a ConfigValue that is not mergeable until after + * substitutions are resolved. Basically these are special ConfigValue that + * never appear in a resolved tree, like {@link ConfigSubstitution} and + * {@link ConfigDelayedMerge}. + */ +interface Unmergeable { + Collection unmergedValues(); +} diff --git a/src/main/java/com/typesafe/config/impl/Unresolved.java b/src/main/java/com/typesafe/config/impl/Unresolved.java deleted file mode 100644 index 3bd1d1d4..00000000 --- a/src/main/java/com/typesafe/config/impl/Unresolved.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.typesafe.config.impl; - -import java.util.Collection; - -/** - * Interface that tags a ConfigValue that is inherently not resolved; i.e. a - * subclass of ConfigValue that will not appear in a resolved tree of values. - * Types such as ConfigObject may not be resolved _yet_, but they are not - * inherently unresolved. - */ -interface Unresolved { - Collection unmergedValues(); -}