mirror of
https://github.com/lightbend/config.git
synced 2025-03-19 13:50:40 +08:00
rename getAny to getAnyRef
makes it a better name in Scala
This commit is contained in:
parent
3019aec77f
commit
9a187a2de9
@ -43,7 +43,7 @@ public interface ConfigObject extends ConfigValue, Map<String, ConfigValue> {
|
||||
* Gets the value at the path as an unwrapped Java boxed value (Boolean,
|
||||
* Integer, Long, etc.)
|
||||
*/
|
||||
Object getAny(String path);
|
||||
Object getAnyRef(String path);
|
||||
|
||||
/**
|
||||
* Gets the value at the given path, unless the value is a null value or
|
||||
@ -99,7 +99,7 @@ public interface ConfigObject extends ConfigValue, Map<String, ConfigValue> {
|
||||
|
||||
List<? extends ConfigObject> getObjectList(String path);
|
||||
|
||||
List<? extends Object> getAnyList(String path);
|
||||
List<? extends Object> getAnyRefList(String path);
|
||||
|
||||
List<Long> getMemorySizeList(String path);
|
||||
|
||||
|
@ -307,7 +307,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAny(String path) {
|
||||
public Object getAnyRef(String path) {
|
||||
ConfigValue v = find(path, null, path);
|
||||
return v.unwrapped();
|
||||
}
|
||||
@ -423,7 +423,7 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Object> getAnyList(String path) {
|
||||
public List<? extends Object> getAnyRefList(String path) {
|
||||
List<Object> l = new ArrayList<Object>();
|
||||
List<? extends ConfigValue> list = getList(path);
|
||||
for (ConfigValue v : list) {
|
||||
|
@ -258,7 +258,8 @@ class ConfigSubstitutionTest extends TestUtils {
|
||||
"pwd" : ${PWD},
|
||||
"shell" : ${SHELL},
|
||||
"lang" : ${LANG},
|
||||
"path" : ${PATH}
|
||||
"path" : ${PATH},
|
||||
"not_here" : ${NOT_HERE}
|
||||
}
|
||||
""")
|
||||
}
|
||||
@ -276,7 +277,7 @@ class ConfigSubstitutionTest extends TestUtils {
|
||||
existed += 1
|
||||
assertEquals(e, resolved.getString(k))
|
||||
} else {
|
||||
assertEquals(null, resolved.getAny(k))
|
||||
assertEquals(nullValue, resolved.get(k))
|
||||
}
|
||||
}
|
||||
if (existed == 0) {
|
||||
|
@ -167,12 +167,12 @@ class ConfigTest extends TestUtils {
|
||||
assertEquals(stringValue("abcd"), conf.getValue("strings.abcd"))
|
||||
|
||||
// get stuff with getAny
|
||||
assertEquals(42L, conf.getAny("ints.fortyTwo"))
|
||||
assertEquals("abcd", conf.getAny("strings.abcd"))
|
||||
assertEquals(false, conf.getAny("booleans.falseAgain"))
|
||||
assertEquals(42L, conf.getAnyRef("ints.fortyTwo"))
|
||||
assertEquals("abcd", conf.getAnyRef("strings.abcd"))
|
||||
assertEquals(false, conf.getAnyRef("booleans.falseAgain"))
|
||||
|
||||
// get empty array as any type of array
|
||||
assertEquals(Seq(), conf.getAnyList("arrays.empty").asScala)
|
||||
assertEquals(Seq(), conf.getAnyRefList("arrays.empty").asScala)
|
||||
assertEquals(Seq(), conf.getIntList("arrays.empty").asScala)
|
||||
assertEquals(Seq(), conf.getLongList("arrays.empty").asScala)
|
||||
assertEquals(Seq(), conf.getStringList("arrays.empty").asScala)
|
||||
@ -188,9 +188,9 @@ class ConfigTest extends TestUtils {
|
||||
assertEquals(Seq(1L, 2L, 3L), conf.getLongList("arrays.ofInt").asScala)
|
||||
assertEquals(Seq("a", "b", "c"), conf.getStringList("arrays.ofString").asScala)
|
||||
assertEquals(Seq(3.14, 4.14, 5.14), conf.getDoubleList("arrays.ofDouble").asScala)
|
||||
assertEquals(Seq(null, null, null), conf.getAnyList("arrays.ofNull").asScala)
|
||||
assertEquals(Seq(null, null, null), conf.getAnyRefList("arrays.ofNull").asScala)
|
||||
assertEquals(Seq(true, false), conf.getBooleanList("arrays.ofBoolean").asScala)
|
||||
val listOfLists = conf.getAnyList("arrays.ofArray").asScala map { _.asInstanceOf[java.util.List[_]].asScala }
|
||||
val listOfLists = conf.getAnyRefList("arrays.ofArray").asScala map { _.asInstanceOf[java.util.List[_]].asScala }
|
||||
assertEquals(Seq(Seq("a", "b", "c"), Seq("a", "b", "c"), Seq("a", "b", "c")), listOfLists)
|
||||
assertEquals(3, conf.getObjectList("arrays.ofObject").asScala.length)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user