Skip to content

Commit

Permalink
Apply Config.inMemoryUniversal shortcut when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
TheElectronWill committed Apr 14, 2019
1 parent f6a491a commit 49bc2b1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public class ConcurrentConfigSpec extends ConfigSpec {
public ConcurrentConfigSpec() {
super(InMemoryFormat.withUniversalSupport().createConcurrentConfig());
super(Config.inMemoryUniversalConcurrent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ConfigSpec {
protected final Config storage;

public ConfigSpec() {
this(InMemoryFormat.withUniversalSupport().createConfig());
this(Config.inMemoryUniversal());
}

ConfigSpec(Config storage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ final class SimpleConfig extends AbstractConfig {
* @param configFormat the config's format
* @param concurrent
*/
SimpleConfig(UnmodifiableConfig toCopy, ConfigFormat<?> configFormat,
boolean concurrent) {
SimpleConfig(UnmodifiableConfig toCopy, ConfigFormat<?> configFormat, boolean concurrent) {
super(toCopy, concurrent);
this.configFormat = configFormat;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void basicTest() {
config.set("stringList", stringList);
assertSame(stringList, config.get("stringList"));

Config subConfig = InMemoryFormat.withUniversalSupport().createConfig();
Config subConfig = Config.inMemoryUniversal();
subConfig.set("string", "test!");
subConfig.set("subSubConfig.string", "another test!");
config.set("subConfig", subConfig);
Expand Down Expand Up @@ -84,7 +84,7 @@ public void specialCase() {
String[] jsplit = ".a...a.".split("\\.");
System.out.println("String#split: " + Arrays.toString(jsplit));

Config config = InMemoryFormat.withUniversalSupport().createConfig();
Config config = Config.inMemoryUniversal();
config.set(".a...a.", "value");
assertTrue(config.contains(".a...a."));
assertEquals("value", config.get(".a...a."));
Expand All @@ -102,11 +102,11 @@ public void specialCase() {

@Test
public void size() {
Config config = InMemoryFormat.withUniversalSupport().createConfig();
Config config = Config.inMemoryUniversal();
config.set("a.b.c", "value");
config.set("pi", PI);

Config subConfig = InMemoryFormat.withUniversalSupport().createConfig();
Config subConfig = Config.inMemoryUniversal();
subConfig.set("string", "test!");
config.set("subConfig", subConfig);

Expand All @@ -116,7 +116,7 @@ public void size() {

@Test
public void asMap() {
Config config = InMemoryFormat.withUniversalSupport().createConfig();
Config config = Config.inMemoryUniversal();
config.set("a.b.c", "value");
config.set("pi", PI);

Expand All @@ -136,7 +136,7 @@ public void asMap() {

@Test
public void containsValue() {
Config config = InMemoryFormat.withUniversalSupport().createConfig();
Config config = Config.inMemoryUniversal();
config.set("a.b.c", "value");
assertTrue(config.contains("a"));
assertFalse(config.contains("b"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ObjectConverterTest {
nestedList3 = Arrays.asList(nestedList2, nestedList2);
}

static final Config config1 = InMemoryFormat.withUniversalSupport().createConfig();
static final Config config1 = Config.inMemoryUniversal();
static final Config config2 = Config.inMemory();

private final Config config = Config.inMemory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testSupportBasic() {
@Test
public void testSupportAll() {
ObjectConverter converter = new ObjectConverter();
Config config = InMemoryFormat.withUniversalSupport().createConfig();
Config config = Config.inMemoryUniversal();
// withUniversalSupport() causes the configuration to accept any type of values without conversion

MyObject object = new MyObject();
Expand Down Expand Up @@ -92,7 +92,7 @@ private static class MyObject {
String string = "value";
List<String> stringList = Arrays.asList("a", "b", "c");
List<SomeObject> objList = objects;
Config config = InMemoryFormat.withUniversalSupport().createConfig();
Config config = Config.inMemoryUniversal();
MyObject subObject;

@Conversion(CoordinatesConverter.class)
Expand Down

0 comments on commit 49bc2b1

Please sign in to comment.