mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
use internal AbstractConfigValue instead of public ConfigValue throughout implementation
In practice don't want to try to support custom ConfigValue.
This commit is contained in:
parent
e11f117200
commit
64c6c753e5
@ -52,7 +52,7 @@ public interface ConfigObject extends ConfigValue {
|
||||
*/
|
||||
Long getNanoseconds(String path);
|
||||
|
||||
List<ConfigValue> getList(String path);
|
||||
List<? extends ConfigValue> getList(String path);
|
||||
|
||||
List<Boolean> getBooleanList(String path);
|
||||
|
||||
@ -64,9 +64,9 @@ public interface ConfigObject extends ConfigValue {
|
||||
|
||||
List<Double> getDoubleList(String path);
|
||||
|
||||
List<ConfigObject> getObjectList(String path);
|
||||
List<? extends ConfigObject> getObjectList(String path);
|
||||
|
||||
List<Object> getAnyList(String path);
|
||||
List<? extends Object> getAnyList(String path);
|
||||
|
||||
List<Long> getMemorySizeList(String path);
|
||||
|
||||
|
@ -31,14 +31,15 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
* @param key
|
||||
* @return the unmodified raw value or null
|
||||
*/
|
||||
protected abstract ConfigValue peek(String key);
|
||||
protected abstract AbstractConfigValue peek(String key);
|
||||
|
||||
protected ConfigValue peek(String key, SubstitutionResolver resolver,
|
||||
protected AbstractConfigValue peek(String key,
|
||||
SubstitutionResolver resolver,
|
||||
int depth, boolean withFallbacks) {
|
||||
ConfigValue v = peek(key);
|
||||
AbstractConfigValue v = peek(key);
|
||||
|
||||
if (v != null && resolver != null) {
|
||||
v = resolver.resolve((AbstractConfigValue) v, depth, withFallbacks);
|
||||
v = resolver.resolve(v, depth, withFallbacks);
|
||||
}
|
||||
|
||||
return v;
|
||||
@ -110,20 +111,17 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
return transformed(obj, transformer);
|
||||
}
|
||||
|
||||
static private ConfigValue resolve(AbstractConfigObject self,
|
||||
static private AbstractConfigValue resolve(AbstractConfigObject self,
|
||||
String path,
|
||||
ConfigValueType expected, ConfigTransformer transformer,
|
||||
String originalPath) {
|
||||
String key = ConfigUtil.firstElement(path);
|
||||
String next = ConfigUtil.otherElements(path);
|
||||
if (next == null) {
|
||||
ConfigValue v = self.peek(key);
|
||||
AbstractConfigValue v = self.peek(key);
|
||||
if (v == null)
|
||||
throw new ConfigException.Missing(originalPath);
|
||||
|
||||
// FIXME if ConfigTransformer remains public API then
|
||||
// casting to AbstractConfigValue here is broken,
|
||||
// but want to make it not public API.
|
||||
if (expected != null && transformer != null)
|
||||
v = transformer.transform(v, expected);
|
||||
|
||||
@ -136,13 +134,13 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
else
|
||||
return v;
|
||||
} else {
|
||||
AbstractConfigObject o = (AbstractConfigObject) self.getObject(key);
|
||||
AbstractConfigObject o = self.getObject(key);
|
||||
assert (o != null); // missing was supposed to throw
|
||||
return resolve(o, next, expected, transformer, originalPath);
|
||||
}
|
||||
}
|
||||
|
||||
ConfigValue resolve(String path, ConfigValueType expected,
|
||||
AbstractConfigValue resolve(String path, ConfigValueType expected,
|
||||
String originalPath) {
|
||||
return resolve(this, path, expected, transformer, originalPath);
|
||||
}
|
||||
@ -158,17 +156,17 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
ConfigTransformer transformer) {
|
||||
if (stack.isEmpty()) {
|
||||
return new SimpleConfigObject(origin, transformer,
|
||||
Collections.<String, ConfigValue> emptyMap());
|
||||
Collections.<String, AbstractConfigValue> emptyMap());
|
||||
} else if (stack.size() == 1) {
|
||||
return transformed(stack.get(0), transformer);
|
||||
} else {
|
||||
// for non-objects, we just take the first value; but for objects we
|
||||
// have to do work to combine them.
|
||||
Map<String, ConfigValue> merged = new HashMap<String, ConfigValue>();
|
||||
Map<String, AbstractConfigValue> merged = new HashMap<String, AbstractConfigValue>();
|
||||
Map<String, List<AbstractConfigObject>> objects = new HashMap<String, List<AbstractConfigObject>>();
|
||||
for (AbstractConfigObject obj : stack) {
|
||||
for (String key : obj.keySet()) {
|
||||
ConfigValue v = obj.peek(key);
|
||||
AbstractConfigValue v = obj.peek(key);
|
||||
if (!merged.containsKey(key)) {
|
||||
if (v.valueType() == ConfigValueType.OBJECT) {
|
||||
// requires recursive merge and transformer fixup
|
||||
@ -203,9 +201,9 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
AbstractConfigObject resolveSubstitutions(SubstitutionResolver resolver,
|
||||
int depth,
|
||||
boolean withFallbacks) {
|
||||
Map<String, ConfigValue> changes = new HashMap<String, ConfigValue>();
|
||||
Map<String, AbstractConfigValue> changes = new HashMap<String, AbstractConfigValue>();
|
||||
for (String k : keySet()) {
|
||||
AbstractConfigValue v = (AbstractConfigValue) peek(k);
|
||||
AbstractConfigValue v = peek(k);
|
||||
AbstractConfigValue resolved = resolver.resolve(v, depth,
|
||||
withFallbacks);
|
||||
if (resolved != v) {
|
||||
@ -215,7 +213,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
if (changes.isEmpty()) {
|
||||
return this;
|
||||
} else {
|
||||
Map<String, ConfigValue> resolved = new HashMap<String, ConfigValue>();
|
||||
Map<String, AbstractConfigValue> resolved = new HashMap<String, AbstractConfigValue>();
|
||||
for (String k : keySet()) {
|
||||
if (changes.containsKey(k)) {
|
||||
resolved.put(k, changes.get(k));
|
||||
@ -266,8 +264,8 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigValue> getList(String path) {
|
||||
ConfigValue v = resolve(path, ConfigValueType.LIST, path);
|
||||
public List<? extends ConfigValue> getList(String path) {
|
||||
AbstractConfigValue v = resolve(path, ConfigValueType.LIST, path);
|
||||
return ((ConfigList) v).asJavaList();
|
||||
}
|
||||
|
||||
@ -318,8 +316,10 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
private <T> List<T> getHomogeneousUnwrappedList(String path,
|
||||
ConfigValueType expected) {
|
||||
List<T> l = new ArrayList<T>();
|
||||
List<ConfigValue> list = getList(path);
|
||||
for (ConfigValue v : list) {
|
||||
List<? extends ConfigValue> list = getList(path);
|
||||
for (ConfigValue cv : list) {
|
||||
// variance would be nice, but stupid cast will do
|
||||
AbstractConfigValue v = (AbstractConfigValue) cv;
|
||||
if (expected != null && transformer != null) {
|
||||
v = transformer.transform(v, expected);
|
||||
}
|
||||
@ -375,7 +375,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
@Override
|
||||
public List<ConfigObject> getObjectList(String path) {
|
||||
List<ConfigObject> l = new ArrayList<ConfigObject>();
|
||||
List<ConfigValue> list = getList(path);
|
||||
List<? extends ConfigValue> list = getList(path);
|
||||
for (ConfigValue v : list) {
|
||||
if (v.valueType() != ConfigValueType.OBJECT)
|
||||
throw new ConfigException.WrongType(v.origin(), path,
|
||||
@ -386,9 +386,9 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getAnyList(String path) {
|
||||
public List<? extends Object> getAnyList(String path) {
|
||||
List<Object> l = new ArrayList<Object>();
|
||||
List<ConfigValue> list = getList(path);
|
||||
List<? extends ConfigValue> list = getList(path);
|
||||
for (ConfigValue v : list) {
|
||||
l.add(v.unwrapped());
|
||||
}
|
||||
@ -398,7 +398,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
@Override
|
||||
public List<Long> getMemorySizeList(String path) {
|
||||
List<Long> l = new ArrayList<Long>();
|
||||
List<ConfigValue> list = getList(path);
|
||||
List<? extends ConfigValue> list = getList(path);
|
||||
for (ConfigValue v : list) {
|
||||
if (v.valueType() == ConfigValueType.NUMBER) {
|
||||
l.add(((Number) v.unwrapped()).longValue());
|
||||
@ -428,7 +428,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
@Override
|
||||
public List<Long> getNanosecondsList(String path) {
|
||||
List<Long> l = new ArrayList<Long>();
|
||||
List<ConfigValue> list = getList(path);
|
||||
List<? extends ConfigValue> list = getList(path);
|
||||
for (ConfigValue v : list) {
|
||||
if (v.valueType() == ConfigValueType.NUMBER) {
|
||||
l.add(((Number) v.unwrapped()).longValue());
|
||||
|
@ -11,7 +11,6 @@ import java.util.Properties;
|
||||
import com.typesafe.config.ConfigConfig;
|
||||
import com.typesafe.config.ConfigException;
|
||||
import com.typesafe.config.ConfigObject;
|
||||
import com.typesafe.config.ConfigValue;
|
||||
|
||||
/** This is public but is only supposed to be used by the "config" package */
|
||||
public class ConfigImpl {
|
||||
@ -96,7 +95,7 @@ public class ConfigImpl {
|
||||
|
||||
private static AbstractConfigObject fromProperties(String originPrefix,
|
||||
Properties props) {
|
||||
Map<String, Map<String, ConfigValue>> scopes = new HashMap<String, Map<String, ConfigValue>>();
|
||||
Map<String, Map<String, AbstractConfigValue>> scopes = new HashMap<String, Map<String, AbstractConfigValue>>();
|
||||
Enumeration<?> i = props.propertyNames();
|
||||
while (i.hasMoreElements()) {
|
||||
Object o = i.nextElement();
|
||||
@ -107,9 +106,10 @@ public class ConfigImpl {
|
||||
String exceptLast = ConfigUtil.exceptLastElement(path);
|
||||
if (exceptLast == null)
|
||||
exceptLast = "";
|
||||
Map<String, ConfigValue> scope = scopes.get(exceptLast);
|
||||
Map<String, AbstractConfigValue> scope = scopes
|
||||
.get(exceptLast);
|
||||
if (scope == null) {
|
||||
scope = new HashMap<String, ConfigValue>();
|
||||
scope = new HashMap<String, AbstractConfigValue>();
|
||||
scopes.put(exceptLast, scope);
|
||||
}
|
||||
String value = props.getProperty(path);
|
||||
@ -134,26 +134,27 @@ public class ConfigImpl {
|
||||
if (parentPath == null)
|
||||
parentPath = "";
|
||||
|
||||
Map<String, ConfigValue> parent = scopes.get(parentPath);
|
||||
Map<String, AbstractConfigValue> parent = scopes.get(parentPath);
|
||||
if (parent == null) {
|
||||
parent = new HashMap<String, ConfigValue>();
|
||||
parent = new HashMap<String, AbstractConfigValue>();
|
||||
scopes.put(parentPath, parent);
|
||||
}
|
||||
// NOTE: we are evil and cheating, we mutate the map we
|
||||
// provide to SimpleConfigObject, which is not allowed by
|
||||
// its contract, but since we know nobody has a ref to this
|
||||
// SimpleConfigObject yet we can get away with it.
|
||||
ConfigObject o = new SimpleConfigObject(new SimpleConfigOrigin(
|
||||
AbstractConfigObject o = new SimpleConfigObject(
|
||||
new SimpleConfigOrigin(
|
||||
originPrefix + " " + path), null, scopes.get(path));
|
||||
String basename = ConfigUtil.lastElement(path);
|
||||
parent.put(basename, o);
|
||||
}
|
||||
|
||||
Map<String, ConfigValue> root = scopes.get("");
|
||||
Map<String, AbstractConfigValue> root = scopes.get("");
|
||||
if (root == null) {
|
||||
// this would happen only if you had no properties at all
|
||||
// in "props"
|
||||
root = Collections.<String, ConfigValue> emptyMap();
|
||||
root = Collections.<String, AbstractConfigValue> emptyMap();
|
||||
}
|
||||
|
||||
// return root config object
|
||||
@ -172,7 +173,7 @@ public class ConfigImpl {
|
||||
|
||||
private static AbstractConfigObject loadEnvVariables() {
|
||||
Map<String, String> env = System.getenv();
|
||||
Map<String, ConfigValue> m = new HashMap<String, ConfigValue>();
|
||||
Map<String, AbstractConfigValue> m = new HashMap<String, AbstractConfigValue>();
|
||||
for (String key : env.keySet()) {
|
||||
m.put(key, new ConfigString(
|
||||
new SimpleConfigOrigin("env var " + key), env.get(key)));
|
||||
|
@ -10,14 +10,14 @@ import com.typesafe.config.ConfigValueType;
|
||||
|
||||
final class ConfigList extends AbstractConfigValue {
|
||||
|
||||
private List<ConfigValue> value;
|
||||
private List<AbstractConfigValue> value;
|
||||
|
||||
ConfigList(ConfigOrigin origin, List<ConfigValue> value) {
|
||||
ConfigList(ConfigOrigin origin, List<AbstractConfigValue> value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
List<ConfigValue> asJavaList() {
|
||||
List<? extends ConfigValue> asJavaList() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -29,25 +29,25 @@ final class ConfigList extends AbstractConfigValue {
|
||||
@Override
|
||||
public List<Object> unwrapped() {
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
for (ConfigValue v : value) {
|
||||
for (AbstractConfigValue v : value) {
|
||||
list.add(v.unwrapped());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
ConfigList resolveSubstitutions(SubstitutionResolver resolver,
|
||||
int depth,
|
||||
ConfigList resolveSubstitutions(SubstitutionResolver resolver, int depth,
|
||||
boolean withFallbacks) {
|
||||
List<ConfigValue> changed = null; // lazy-create for optimization
|
||||
// lazy-create for optimization
|
||||
List<AbstractConfigValue> changed = null;
|
||||
int i = 0;
|
||||
for (ConfigValue v : value) {
|
||||
AbstractConfigValue resolved = resolver.resolve(
|
||||
(AbstractConfigValue) v, depth, withFallbacks);
|
||||
for (AbstractConfigValue v : value) {
|
||||
AbstractConfigValue resolved = resolver.resolve(v, depth,
|
||||
withFallbacks);
|
||||
|
||||
// lazy-create the new list if required
|
||||
if (changed == null && resolved != v) {
|
||||
changed = new ArrayList<ConfigValue>();
|
||||
changed = new ArrayList<AbstractConfigValue>();
|
||||
for (int j = 0; j < i; ++j) {
|
||||
changed.add(value.get(j));
|
||||
}
|
||||
|
@ -1,17 +1,27 @@
|
||||
package com.typesafe.config.impl;
|
||||
|
||||
import com.typesafe.config.ConfigValue;
|
||||
import com.typesafe.config.ConfigValueType;
|
||||
|
||||
/**
|
||||
* A ConfigTransformer converts values in the config to other values, most often
|
||||
* it's used to parse strings and treat them as some other kind of value.
|
||||
*
|
||||
*
|
||||
* This was originally in the public API but I'm now thinking it is not useful
|
||||
* to customize, so it's not public for now. It's still used internally, but
|
||||
* probably the code could be cleaned up by just hard-coding the equivalent of
|
||||
* the DefaultTransformer.
|
||||
*/
|
||||
interface ConfigTransformer {
|
||||
ConfigValue transform(ConfigValue value, ConfigValueType requested);
|
||||
/**
|
||||
* Because this interface is currently private, it uses AbstractConfigValue;
|
||||
* if public it would have to use plain ConfigValue.
|
||||
*
|
||||
* @param value
|
||||
* the value to potentially transform
|
||||
* @param requested
|
||||
* the target type to transform to
|
||||
* @return a new value or the original value
|
||||
*/
|
||||
AbstractConfigValue transform(AbstractConfigValue value,
|
||||
ConfigValueType requested);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.typesafe.config.impl;
|
||||
|
||||
import com.typesafe.config.ConfigValue;
|
||||
import com.typesafe.config.ConfigValueType;
|
||||
|
||||
/**
|
||||
@ -9,7 +8,8 @@ import com.typesafe.config.ConfigValueType;
|
||||
class DefaultTransformer implements ConfigTransformer {
|
||||
|
||||
@Override
|
||||
public ConfigValue transform(ConfigValue value, ConfigValueType requested) {
|
||||
public AbstractConfigValue transform(AbstractConfigValue value,
|
||||
ConfigValueType requested) {
|
||||
if (value.valueType() == ConfigValueType.STRING) {
|
||||
String s = (String) value.unwrapped();
|
||||
switch (requested) {
|
||||
@ -47,7 +47,7 @@ class DefaultTransformer implements ConfigTransformer {
|
||||
case NUMBER: // FALL THROUGH
|
||||
case BOOLEAN:
|
||||
return new ConfigString(value.origin(),
|
||||
((AbstractConfigValue) value).transformToString());
|
||||
value.transformToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import java.util.Stack;
|
||||
|
||||
import com.typesafe.config.ConfigException;
|
||||
import com.typesafe.config.ConfigOrigin;
|
||||
import com.typesafe.config.ConfigValue;
|
||||
import com.typesafe.config.ConfigValueType;
|
||||
|
||||
final class Parser {
|
||||
@ -243,7 +242,7 @@ final class Parser {
|
||||
|
||||
private AbstractConfigObject parseObject() {
|
||||
// invoked just after the OPEN_CURLY
|
||||
Map<String, ConfigValue> values = new HashMap<String, ConfigValue>();
|
||||
Map<String, AbstractConfigValue> values = new HashMap<String, AbstractConfigValue>();
|
||||
ConfigOrigin objectOrigin = lineOrigin();
|
||||
while (true) {
|
||||
Token t = nextTokenIgnoringNewline();
|
||||
@ -286,7 +285,7 @@ final class Parser {
|
||||
private ConfigList parseArray() {
|
||||
// invoked just after the OPEN_SQUARE
|
||||
ConfigOrigin arrayOrigin = lineOrigin();
|
||||
List<ConfigValue> values = new ArrayList<ConfigValue>();
|
||||
List<AbstractConfigValue> values = new ArrayList<AbstractConfigValue>();
|
||||
|
||||
consolidateValueTokens();
|
||||
|
||||
@ -295,7 +294,7 @@ final class Parser {
|
||||
// special-case the first element
|
||||
if (t == Tokens.CLOSE_SQUARE) {
|
||||
return new ConfigList(arrayOrigin,
|
||||
Collections.<ConfigValue> emptyList());
|
||||
Collections.<AbstractConfigValue> emptyList());
|
||||
} else if (Tokens.isValue(t)) {
|
||||
values.add(parseValue(t));
|
||||
} else if (t == Tokens.OPEN_CURLY) {
|
||||
|
@ -7,15 +7,14 @@ import java.util.Set;
|
||||
import com.typesafe.config.ConfigException;
|
||||
import com.typesafe.config.ConfigObject;
|
||||
import com.typesafe.config.ConfigOrigin;
|
||||
import com.typesafe.config.ConfigValue;
|
||||
|
||||
class SimpleConfigObject extends AbstractConfigObject {
|
||||
|
||||
// this map should never be modified - assume immutable
|
||||
private Map<String, ConfigValue> value;
|
||||
private Map<String, AbstractConfigValue> value;
|
||||
|
||||
SimpleConfigObject(ConfigOrigin origin, ConfigTransformer transformer,
|
||||
Map<String, ConfigValue> value) {
|
||||
Map<String, AbstractConfigValue> value) {
|
||||
super(origin, transformer);
|
||||
if (value == null)
|
||||
throw new ConfigException.BugOrBroken(
|
||||
@ -24,7 +23,7 @@ class SimpleConfigObject extends AbstractConfigObject {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigValue peek(String key) {
|
||||
protected AbstractConfigValue peek(String key) {
|
||||
return value.get(key);
|
||||
}
|
||||
|
||||
@ -47,8 +46,8 @@ class SimpleConfigObject extends AbstractConfigObject {
|
||||
return value.keySet();
|
||||
}
|
||||
|
||||
private static boolean mapEquals(Map<String, ConfigValue> a,
|
||||
Map<String, ConfigValue> b) {
|
||||
private static boolean mapEquals(Map<String, AbstractConfigValue> a,
|
||||
Map<String, AbstractConfigValue> b) {
|
||||
Set<String> aKeys = a.keySet();
|
||||
Set<String> bKeys = b.keySet();
|
||||
|
||||
@ -62,7 +61,7 @@ class SimpleConfigObject extends AbstractConfigObject {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int mapHash(Map<String, ConfigValue> m) {
|
||||
private static int mapHash(Map<String, AbstractConfigValue> m) {
|
||||
Set<String> keys = m.keySet();
|
||||
int valuesHash = 0;
|
||||
for (String k : keys) {
|
||||
|
@ -8,7 +8,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.typesafe.config.ConfigOrigin;
|
||||
import com.typesafe.config.ConfigValue;
|
||||
|
||||
/**
|
||||
* This is unused for now, decided that it was too annoying to "lazy merge" and
|
||||
@ -64,11 +63,11 @@ final class StackConfigObject extends AbstractConfigObject {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigValue peek(String key) {
|
||||
protected AbstractConfigValue peek(String key) {
|
||||
for (AbstractConfigObject o : stack) {
|
||||
// Important: A ConfigNull value would override
|
||||
// and keep us from returning a later non-null value.
|
||||
ConfigValue v = o.peek(key);
|
||||
AbstractConfigValue v = o.peek(key);
|
||||
if (v != null)
|
||||
return v;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.typesafe.config.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.typesafe.config.ConfigValue;
|
||||
import com.typesafe.config.ConfigValueType;
|
||||
|
||||
final class StackTransformer implements ConfigTransformer {
|
||||
@ -14,8 +13,9 @@ final class StackTransformer implements ConfigTransformer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigValue transform(ConfigValue value, ConfigValueType requested) {
|
||||
ConfigValue current = value;
|
||||
public AbstractConfigValue transform(AbstractConfigValue value,
|
||||
ConfigValueType requested) {
|
||||
AbstractConfigValue current = value;
|
||||
for (ConfigTransformer t : stack) {
|
||||
current = t.transform(current, requested);
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.typesafe.config.impl;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.typesafe.config.ConfigValue;
|
||||
|
||||
class TransformedConfigObject extends AbstractConfigObject {
|
||||
|
||||
private AbstractConfigObject underlying;
|
||||
@ -30,7 +28,7 @@ class TransformedConfigObject extends AbstractConfigObject {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigValue peek(String key) {
|
||||
protected AbstractConfigValue peek(String key) {
|
||||
return underlying.peek(key);
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ class ConfigValueTest extends TestUtils {
|
||||
checkNotEqualObjects(intValueB, longValue)
|
||||
}
|
||||
|
||||
private def configMap(pairs: (String, Int)*): java.util.Map[String, ConfigValue] = {
|
||||
val m = new java.util.HashMap[String, ConfigValue]()
|
||||
private def configMap(pairs: (String, Int)*): java.util.Map[String, AbstractConfigValue] = {
|
||||
val m = new java.util.HashMap[String, AbstractConfigValue]()
|
||||
for (p <- pairs) {
|
||||
m.put(p._1, new ConfigInt(fakeOrigin(), p._2))
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ class ParseTest extends TestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private[this] def fromLift(liftValue: lift.JValue): ConfigValue = {
|
||||
private[this] def fromLift(liftValue: lift.JValue): AbstractConfigValue = {
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
liftValue match {
|
||||
case lift.JObject(fields) =>
|
||||
val m = new HashMap[String, ConfigValue]()
|
||||
val m = new HashMap[String, AbstractConfigValue]()
|
||||
fields.foreach({ field => m.put(field.name, fromLift(field.value)) })
|
||||
new SimpleConfigObject(fakeOrigin(), null, m)
|
||||
case lift.JArray(values) =>
|
||||
|
Loading…
Reference in New Issue
Block a user