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:
Havoc Pennington 2011-11-08 22:03:22 -05:00
parent e11f117200
commit 64c6c753e5
13 changed files with 86 additions and 80 deletions

View File

@ -52,7 +52,7 @@ public interface ConfigObject extends ConfigValue {
*/ */
Long getNanoseconds(String path); Long getNanoseconds(String path);
List<ConfigValue> getList(String path); List<? extends ConfigValue> getList(String path);
List<Boolean> getBooleanList(String path); List<Boolean> getBooleanList(String path);
@ -64,9 +64,9 @@ public interface ConfigObject extends ConfigValue {
List<Double> getDoubleList(String path); 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); List<Long> getMemorySizeList(String path);

View File

@ -31,14 +31,15 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
* @param key * @param key
* @return the unmodified raw value or null * @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) { int depth, boolean withFallbacks) {
ConfigValue v = peek(key); AbstractConfigValue v = peek(key);
if (v != null && resolver != null) { if (v != null && resolver != null) {
v = resolver.resolve((AbstractConfigValue) v, depth, withFallbacks); v = resolver.resolve(v, depth, withFallbacks);
} }
return v; return v;
@ -110,20 +111,17 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
return transformed(obj, transformer); return transformed(obj, transformer);
} }
static private ConfigValue resolve(AbstractConfigObject self, static private AbstractConfigValue resolve(AbstractConfigObject self,
String path, String path,
ConfigValueType expected, ConfigTransformer transformer, ConfigValueType expected, ConfigTransformer transformer,
String originalPath) { String originalPath) {
String key = ConfigUtil.firstElement(path); String key = ConfigUtil.firstElement(path);
String next = ConfigUtil.otherElements(path); String next = ConfigUtil.otherElements(path);
if (next == null) { if (next == null) {
ConfigValue v = self.peek(key); AbstractConfigValue v = self.peek(key);
if (v == null) if (v == null)
throw new ConfigException.Missing(originalPath); 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) if (expected != null && transformer != null)
v = transformer.transform(v, expected); v = transformer.transform(v, expected);
@ -136,13 +134,13 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
else else
return v; return v;
} else { } else {
AbstractConfigObject o = (AbstractConfigObject) self.getObject(key); AbstractConfigObject o = self.getObject(key);
assert (o != null); // missing was supposed to throw assert (o != null); // missing was supposed to throw
return resolve(o, next, expected, transformer, originalPath); return resolve(o, next, expected, transformer, originalPath);
} }
} }
ConfigValue resolve(String path, ConfigValueType expected, AbstractConfigValue resolve(String path, ConfigValueType expected,
String originalPath) { String originalPath) {
return resolve(this, path, expected, transformer, originalPath); return resolve(this, path, expected, transformer, originalPath);
} }
@ -158,17 +156,17 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
ConfigTransformer transformer) { ConfigTransformer transformer) {
if (stack.isEmpty()) { if (stack.isEmpty()) {
return new SimpleConfigObject(origin, transformer, return new SimpleConfigObject(origin, transformer,
Collections.<String, ConfigValue> emptyMap()); Collections.<String, AbstractConfigValue> emptyMap());
} else if (stack.size() == 1) { } else if (stack.size() == 1) {
return transformed(stack.get(0), transformer); return transformed(stack.get(0), transformer);
} else { } else {
// for non-objects, we just take the first value; but for objects we // for non-objects, we just take the first value; but for objects we
// have to do work to combine them. // 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>>(); Map<String, List<AbstractConfigObject>> objects = new HashMap<String, List<AbstractConfigObject>>();
for (AbstractConfigObject obj : stack) { for (AbstractConfigObject obj : stack) {
for (String key : obj.keySet()) { for (String key : obj.keySet()) {
ConfigValue v = obj.peek(key); AbstractConfigValue v = obj.peek(key);
if (!merged.containsKey(key)) { if (!merged.containsKey(key)) {
if (v.valueType() == ConfigValueType.OBJECT) { if (v.valueType() == ConfigValueType.OBJECT) {
// requires recursive merge and transformer fixup // requires recursive merge and transformer fixup
@ -203,9 +201,9 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
AbstractConfigObject resolveSubstitutions(SubstitutionResolver resolver, AbstractConfigObject resolveSubstitutions(SubstitutionResolver resolver,
int depth, int depth,
boolean withFallbacks) { boolean withFallbacks) {
Map<String, ConfigValue> changes = new HashMap<String, ConfigValue>(); Map<String, AbstractConfigValue> changes = new HashMap<String, AbstractConfigValue>();
for (String k : keySet()) { for (String k : keySet()) {
AbstractConfigValue v = (AbstractConfigValue) peek(k); AbstractConfigValue v = peek(k);
AbstractConfigValue resolved = resolver.resolve(v, depth, AbstractConfigValue resolved = resolver.resolve(v, depth,
withFallbacks); withFallbacks);
if (resolved != v) { if (resolved != v) {
@ -215,7 +213,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
if (changes.isEmpty()) { if (changes.isEmpty()) {
return this; return this;
} else { } else {
Map<String, ConfigValue> resolved = new HashMap<String, ConfigValue>(); Map<String, AbstractConfigValue> resolved = new HashMap<String, AbstractConfigValue>();
for (String k : keySet()) { for (String k : keySet()) {
if (changes.containsKey(k)) { if (changes.containsKey(k)) {
resolved.put(k, changes.get(k)); resolved.put(k, changes.get(k));
@ -266,8 +264,8 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
} }
@Override @Override
public List<ConfigValue> getList(String path) { public List<? extends ConfigValue> getList(String path) {
ConfigValue v = resolve(path, ConfigValueType.LIST, path); AbstractConfigValue v = resolve(path, ConfigValueType.LIST, path);
return ((ConfigList) v).asJavaList(); return ((ConfigList) v).asJavaList();
} }
@ -318,8 +316,10 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
private <T> List<T> getHomogeneousUnwrappedList(String path, private <T> List<T> getHomogeneousUnwrappedList(String path,
ConfigValueType expected) { ConfigValueType expected) {
List<T> l = new ArrayList<T>(); List<T> l = new ArrayList<T>();
List<ConfigValue> list = getList(path); List<? extends ConfigValue> list = getList(path);
for (ConfigValue v : list) { for (ConfigValue cv : list) {
// variance would be nice, but stupid cast will do
AbstractConfigValue v = (AbstractConfigValue) cv;
if (expected != null && transformer != null) { if (expected != null && transformer != null) {
v = transformer.transform(v, expected); v = transformer.transform(v, expected);
} }
@ -375,7 +375,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
@Override @Override
public List<ConfigObject> getObjectList(String path) { public List<ConfigObject> getObjectList(String path) {
List<ConfigObject> l = new ArrayList<ConfigObject>(); List<ConfigObject> l = new ArrayList<ConfigObject>();
List<ConfigValue> list = getList(path); List<? extends ConfigValue> list = getList(path);
for (ConfigValue v : list) { for (ConfigValue v : list) {
if (v.valueType() != ConfigValueType.OBJECT) if (v.valueType() != ConfigValueType.OBJECT)
throw new ConfigException.WrongType(v.origin(), path, throw new ConfigException.WrongType(v.origin(), path,
@ -386,9 +386,9 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
} }
@Override @Override
public List<Object> getAnyList(String path) { public List<? extends Object> getAnyList(String path) {
List<Object> l = new ArrayList<Object>(); List<Object> l = new ArrayList<Object>();
List<ConfigValue> list = getList(path); List<? extends ConfigValue> list = getList(path);
for (ConfigValue v : list) { for (ConfigValue v : list) {
l.add(v.unwrapped()); l.add(v.unwrapped());
} }
@ -398,7 +398,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
@Override @Override
public List<Long> getMemorySizeList(String path) { public List<Long> getMemorySizeList(String path) {
List<Long> l = new ArrayList<Long>(); List<Long> l = new ArrayList<Long>();
List<ConfigValue> list = getList(path); List<? extends ConfigValue> list = getList(path);
for (ConfigValue v : list) { for (ConfigValue v : list) {
if (v.valueType() == ConfigValueType.NUMBER) { if (v.valueType() == ConfigValueType.NUMBER) {
l.add(((Number) v.unwrapped()).longValue()); l.add(((Number) v.unwrapped()).longValue());
@ -428,7 +428,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
@Override @Override
public List<Long> getNanosecondsList(String path) { public List<Long> getNanosecondsList(String path) {
List<Long> l = new ArrayList<Long>(); List<Long> l = new ArrayList<Long>();
List<ConfigValue> list = getList(path); List<? extends ConfigValue> list = getList(path);
for (ConfigValue v : list) { for (ConfigValue v : list) {
if (v.valueType() == ConfigValueType.NUMBER) { if (v.valueType() == ConfigValueType.NUMBER) {
l.add(((Number) v.unwrapped()).longValue()); l.add(((Number) v.unwrapped()).longValue());

View File

@ -11,7 +11,6 @@ import java.util.Properties;
import com.typesafe.config.ConfigConfig; import com.typesafe.config.ConfigConfig;
import com.typesafe.config.ConfigException; import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigObject; import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigValue;
/** This is public but is only supposed to be used by the "config" package */ /** This is public but is only supposed to be used by the "config" package */
public class ConfigImpl { public class ConfigImpl {
@ -96,7 +95,7 @@ public class ConfigImpl {
private static AbstractConfigObject fromProperties(String originPrefix, private static AbstractConfigObject fromProperties(String originPrefix,
Properties props) { 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(); Enumeration<?> i = props.propertyNames();
while (i.hasMoreElements()) { while (i.hasMoreElements()) {
Object o = i.nextElement(); Object o = i.nextElement();
@ -107,9 +106,10 @@ public class ConfigImpl {
String exceptLast = ConfigUtil.exceptLastElement(path); String exceptLast = ConfigUtil.exceptLastElement(path);
if (exceptLast == null) if (exceptLast == null)
exceptLast = ""; exceptLast = "";
Map<String, ConfigValue> scope = scopes.get(exceptLast); Map<String, AbstractConfigValue> scope = scopes
.get(exceptLast);
if (scope == null) { if (scope == null) {
scope = new HashMap<String, ConfigValue>(); scope = new HashMap<String, AbstractConfigValue>();
scopes.put(exceptLast, scope); scopes.put(exceptLast, scope);
} }
String value = props.getProperty(path); String value = props.getProperty(path);
@ -134,26 +134,27 @@ public class ConfigImpl {
if (parentPath == null) if (parentPath == null)
parentPath = ""; parentPath = "";
Map<String, ConfigValue> parent = scopes.get(parentPath); Map<String, AbstractConfigValue> parent = scopes.get(parentPath);
if (parent == null) { if (parent == null) {
parent = new HashMap<String, ConfigValue>(); parent = new HashMap<String, AbstractConfigValue>();
scopes.put(parentPath, parent); scopes.put(parentPath, parent);
} }
// NOTE: we are evil and cheating, we mutate the map we // NOTE: we are evil and cheating, we mutate the map we
// provide to SimpleConfigObject, which is not allowed by // provide to SimpleConfigObject, which is not allowed by
// its contract, but since we know nobody has a ref to this // its contract, but since we know nobody has a ref to this
// SimpleConfigObject yet we can get away with it. // 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)); originPrefix + " " + path), null, scopes.get(path));
String basename = ConfigUtil.lastElement(path); String basename = ConfigUtil.lastElement(path);
parent.put(basename, o); parent.put(basename, o);
} }
Map<String, ConfigValue> root = scopes.get(""); Map<String, AbstractConfigValue> root = scopes.get("");
if (root == null) { if (root == null) {
// this would happen only if you had no properties at all // this would happen only if you had no properties at all
// in "props" // in "props"
root = Collections.<String, ConfigValue> emptyMap(); root = Collections.<String, AbstractConfigValue> emptyMap();
} }
// return root config object // return root config object
@ -172,7 +173,7 @@ public class ConfigImpl {
private static AbstractConfigObject loadEnvVariables() { private static AbstractConfigObject loadEnvVariables() {
Map<String, String> env = System.getenv(); 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()) { for (String key : env.keySet()) {
m.put(key, new ConfigString( m.put(key, new ConfigString(
new SimpleConfigOrigin("env var " + key), env.get(key))); new SimpleConfigOrigin("env var " + key), env.get(key)));

View File

@ -10,14 +10,14 @@ import com.typesafe.config.ConfigValueType;
final class ConfigList extends AbstractConfigValue { 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); super(origin);
this.value = value; this.value = value;
} }
List<ConfigValue> asJavaList() { List<? extends ConfigValue> asJavaList() {
return value; return value;
} }
@ -29,25 +29,25 @@ final class ConfigList extends AbstractConfigValue {
@Override @Override
public List<Object> unwrapped() { public List<Object> unwrapped() {
List<Object> list = new ArrayList<Object>(); List<Object> list = new ArrayList<Object>();
for (ConfigValue v : value) { for (AbstractConfigValue v : value) {
list.add(v.unwrapped()); list.add(v.unwrapped());
} }
return list; return list;
} }
@Override @Override
ConfigList resolveSubstitutions(SubstitutionResolver resolver, ConfigList resolveSubstitutions(SubstitutionResolver resolver, int depth,
int depth,
boolean withFallbacks) { boolean withFallbacks) {
List<ConfigValue> changed = null; // lazy-create for optimization // lazy-create for optimization
List<AbstractConfigValue> changed = null;
int i = 0; int i = 0;
for (ConfigValue v : value) { for (AbstractConfigValue v : value) {
AbstractConfigValue resolved = resolver.resolve( AbstractConfigValue resolved = resolver.resolve(v, depth,
(AbstractConfigValue) v, depth, withFallbacks); withFallbacks);
// lazy-create the new list if required // lazy-create the new list if required
if (changed == null && resolved != v) { if (changed == null && resolved != v) {
changed = new ArrayList<ConfigValue>(); changed = new ArrayList<AbstractConfigValue>();
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
changed.add(value.get(j)); changed.add(value.get(j));
} }

View File

@ -1,17 +1,27 @@
package com.typesafe.config.impl; package com.typesafe.config.impl;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType; import com.typesafe.config.ConfigValueType;
/** /**
* A ConfigTransformer converts values in the config to other values, most often * 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. * 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 * 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 * 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 * probably the code could be cleaned up by just hard-coding the equivalent of
* the DefaultTransformer. * the DefaultTransformer.
*/ */
interface ConfigTransformer { 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);
} }

View File

@ -1,6 +1,5 @@
package com.typesafe.config.impl; package com.typesafe.config.impl;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType; import com.typesafe.config.ConfigValueType;
/** /**
@ -9,7 +8,8 @@ import com.typesafe.config.ConfigValueType;
class DefaultTransformer implements ConfigTransformer { class DefaultTransformer implements ConfigTransformer {
@Override @Override
public ConfigValue transform(ConfigValue value, ConfigValueType requested) { public AbstractConfigValue transform(AbstractConfigValue value,
ConfigValueType requested) {
if (value.valueType() == ConfigValueType.STRING) { if (value.valueType() == ConfigValueType.STRING) {
String s = (String) value.unwrapped(); String s = (String) value.unwrapped();
switch (requested) { switch (requested) {
@ -47,7 +47,7 @@ class DefaultTransformer implements ConfigTransformer {
case NUMBER: // FALL THROUGH case NUMBER: // FALL THROUGH
case BOOLEAN: case BOOLEAN:
return new ConfigString(value.origin(), return new ConfigString(value.origin(),
((AbstractConfigValue) value).transformToString()); value.transformToString());
} }
} }

View File

@ -19,7 +19,6 @@ import java.util.Stack;
import com.typesafe.config.ConfigException; import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigOrigin; import com.typesafe.config.ConfigOrigin;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType; import com.typesafe.config.ConfigValueType;
final class Parser { final class Parser {
@ -243,7 +242,7 @@ final class Parser {
private AbstractConfigObject parseObject() { private AbstractConfigObject parseObject() {
// invoked just after the OPEN_CURLY // 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(); ConfigOrigin objectOrigin = lineOrigin();
while (true) { while (true) {
Token t = nextTokenIgnoringNewline(); Token t = nextTokenIgnoringNewline();
@ -286,7 +285,7 @@ final class Parser {
private ConfigList parseArray() { private ConfigList parseArray() {
// invoked just after the OPEN_SQUARE // invoked just after the OPEN_SQUARE
ConfigOrigin arrayOrigin = lineOrigin(); ConfigOrigin arrayOrigin = lineOrigin();
List<ConfigValue> values = new ArrayList<ConfigValue>(); List<AbstractConfigValue> values = new ArrayList<AbstractConfigValue>();
consolidateValueTokens(); consolidateValueTokens();
@ -295,7 +294,7 @@ final class Parser {
// special-case the first element // special-case the first element
if (t == Tokens.CLOSE_SQUARE) { if (t == Tokens.CLOSE_SQUARE) {
return new ConfigList(arrayOrigin, return new ConfigList(arrayOrigin,
Collections.<ConfigValue> emptyList()); Collections.<AbstractConfigValue> emptyList());
} else if (Tokens.isValue(t)) { } else if (Tokens.isValue(t)) {
values.add(parseValue(t)); values.add(parseValue(t));
} else if (t == Tokens.OPEN_CURLY) { } else if (t == Tokens.OPEN_CURLY) {

View File

@ -7,15 +7,14 @@ import java.util.Set;
import com.typesafe.config.ConfigException; import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigObject; import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigOrigin; import com.typesafe.config.ConfigOrigin;
import com.typesafe.config.ConfigValue;
class SimpleConfigObject extends AbstractConfigObject { class SimpleConfigObject extends AbstractConfigObject {
// this map should never be modified - assume immutable // this map should never be modified - assume immutable
private Map<String, ConfigValue> value; private Map<String, AbstractConfigValue> value;
SimpleConfigObject(ConfigOrigin origin, ConfigTransformer transformer, SimpleConfigObject(ConfigOrigin origin, ConfigTransformer transformer,
Map<String, ConfigValue> value) { Map<String, AbstractConfigValue> value) {
super(origin, transformer); super(origin, transformer);
if (value == null) if (value == null)
throw new ConfigException.BugOrBroken( throw new ConfigException.BugOrBroken(
@ -24,7 +23,7 @@ class SimpleConfigObject extends AbstractConfigObject {
} }
@Override @Override
protected ConfigValue peek(String key) { protected AbstractConfigValue peek(String key) {
return value.get(key); return value.get(key);
} }
@ -47,8 +46,8 @@ class SimpleConfigObject extends AbstractConfigObject {
return value.keySet(); return value.keySet();
} }
private static boolean mapEquals(Map<String, ConfigValue> a, private static boolean mapEquals(Map<String, AbstractConfigValue> a,
Map<String, ConfigValue> b) { Map<String, AbstractConfigValue> b) {
Set<String> aKeys = a.keySet(); Set<String> aKeys = a.keySet();
Set<String> bKeys = b.keySet(); Set<String> bKeys = b.keySet();
@ -62,7 +61,7 @@ class SimpleConfigObject extends AbstractConfigObject {
return true; return true;
} }
private static int mapHash(Map<String, ConfigValue> m) { private static int mapHash(Map<String, AbstractConfigValue> m) {
Set<String> keys = m.keySet(); Set<String> keys = m.keySet();
int valuesHash = 0; int valuesHash = 0;
for (String k : keys) { for (String k : keys) {

View File

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import com.typesafe.config.ConfigOrigin; 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 * 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 @Override
protected ConfigValue peek(String key) { protected AbstractConfigValue peek(String key) {
for (AbstractConfigObject o : stack) { for (AbstractConfigObject o : stack) {
// Important: A ConfigNull value would override // Important: A ConfigNull value would override
// and keep us from returning a later non-null value. // and keep us from returning a later non-null value.
ConfigValue v = o.peek(key); AbstractConfigValue v = o.peek(key);
if (v != null) if (v != null)
return v; return v;
} }

View File

@ -2,7 +2,6 @@ package com.typesafe.config.impl;
import java.util.List; import java.util.List;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType; import com.typesafe.config.ConfigValueType;
final class StackTransformer implements ConfigTransformer { final class StackTransformer implements ConfigTransformer {
@ -14,8 +13,9 @@ final class StackTransformer implements ConfigTransformer {
} }
@Override @Override
public ConfigValue transform(ConfigValue value, ConfigValueType requested) { public AbstractConfigValue transform(AbstractConfigValue value,
ConfigValue current = value; ConfigValueType requested) {
AbstractConfigValue current = value;
for (ConfigTransformer t : stack) { for (ConfigTransformer t : stack) {
current = t.transform(current, requested); current = t.transform(current, requested);
} }

View File

@ -2,8 +2,6 @@ package com.typesafe.config.impl;
import java.util.Set; import java.util.Set;
import com.typesafe.config.ConfigValue;
class TransformedConfigObject extends AbstractConfigObject { class TransformedConfigObject extends AbstractConfigObject {
private AbstractConfigObject underlying; private AbstractConfigObject underlying;
@ -30,7 +28,7 @@ class TransformedConfigObject extends AbstractConfigObject {
} }
@Override @Override
protected ConfigValue peek(String key) { protected AbstractConfigValue peek(String key) {
return underlying.peek(key); return underlying.peek(key);
} }
} }

View File

@ -41,8 +41,8 @@ class ConfigValueTest extends TestUtils {
checkNotEqualObjects(intValueB, longValue) checkNotEqualObjects(intValueB, longValue)
} }
private def configMap(pairs: (String, Int)*): java.util.Map[String, ConfigValue] = { private def configMap(pairs: (String, Int)*): java.util.Map[String, AbstractConfigValue] = {
val m = new java.util.HashMap[String, ConfigValue]() val m = new java.util.HashMap[String, AbstractConfigValue]()
for (p <- pairs) { for (p <- pairs) {
m.put(p._1, new ConfigInt(fakeOrigin(), p._2)) m.put(p._1, new ConfigInt(fakeOrigin(), p._2))
} }

View File

@ -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._ import scala.collection.JavaConverters._
liftValue match { liftValue match {
case lift.JObject(fields) => 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)) }) fields.foreach({ field => m.put(field.name, fromLift(field.value)) })
new SimpleConfigObject(fakeOrigin(), null, m) new SimpleConfigObject(fakeOrigin(), null, m)
case lift.JArray(values) => case lift.JArray(values) =>