Skip to content

Commit

Permalink
#26 - Rename getList() getSet() methods to list() set() with deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Dec 22, 2021
1 parent c585a26 commit 4413bcc
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 38 deletions.
24 changes: 20 additions & 4 deletions src/main/java/io/avaje/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,41 @@ public static <T extends Enum<T>> T getEnum(Class<T> type, String key, T default
*
* <pre>{@code
*
* List<Integer> codes = Config.getList().ofInt("my.codes", 97, 45);
* List<Integer> codes = Config.list().ofInt("my.codes", 97, 45);
*
* }</pre>
*/
public static Configuration.ListValue list() {
return data.list();
}

/**
* Deprecated migrate to list().
*/
@Deprecated
public static Configuration.ListValue getList() {
return data.getList();
return list();
}

/**
* Return a Set of values configured.
*
* <pre>{@code
*
* Set<String> operations = Config.getSet().of("my.operations", "put","delete");
* Set<String> operations = Config.set().of("my.operations", "put","delete");
*
* }</pre>
*/
public static Configuration.SetValue set() {
return data.set();
}

/**
* Deprecated migrate to set().
*/
@Deprecated
public static Configuration.SetValue getSet() {
return data.getSet();
return set();
}

/**
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/io/avaje/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,15 @@ public interface Configuration {
*
* }</pre>
*/
ListValue getList();
ListValue list();

/**
* Deprecated migrate to list().
*/
@Deprecated
default ListValue getList() {
return list();
}

/**
* Return a Set of values configured.
Expand All @@ -199,7 +207,15 @@ public interface Configuration {
*
* }</pre>
*/
SetValue getSet();
SetValue set();

/**
* Deprecated migrate to set().
*/
@Deprecated
default SetValue getSet() {
return set();
}

/**
* Set a configuration value.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/avaje/config/CoreConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ public Properties asProperties() {
}

@Override
public ListValue getList() {
public ListValue list() {
return listValue;
}

@Override
public SetValue getSet() {
public SetValue set() {
return setValue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/avaje/config/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void fallbackToSystemProperty_initial() {
Config.setProperty("MySystemProp0", "caz");
assertThat(Config.get("MySystemProp0")).isEqualTo("caz");

assertThat(Config.getList().of("MySystemProp0")).contains("caz");
assertThat(Config.getSet().of("MySystemProp0")).contains("caz");
assertThat(Config.list().of("MySystemProp0")).contains("caz");
assertThat(Config.set().of("MySystemProp0")).contains("caz");
}

@Test
Expand Down
56 changes: 28 additions & 28 deletions src/test/java/io/avaje/config/CoreConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,38 +136,38 @@ void getURL() throws MalformedURLException {

@Test
void getList() {
assertThat(data.getList().of("someValues")).contains("13", "42", "55");
assertThat(data.getList().of("someValues", "a", "b")).contains("13", "42", "55");
assertThat(data.getList().of("list.notThere", "a", "b")).contains("a", "b");
assertThat(data.getList().of("list.notThere2")).isEmpty();

assertThat(data.getList().ofInt("someValues")).contains(13, 42, 55);
assertThat(data.getList().ofInt("someValues", 22)).contains(13, 42, 55);
assertThat(data.getList().ofInt("list.int.notThere", 51, 52)).contains(51, 52);
assertThat(data.getList().ofInt("list.int.notThere2")).isEmpty();

assertThat(data.getList().ofLong("someValues")).contains(13L, 42L, 55L);
assertThat(data.getList().ofLong("someValues", 22L)).contains(13L, 42L, 55L);
assertThat(data.getList().ofLong("list.long.notThere", 51L, 52L)).contains(51L, 52L);
assertThat(data.getList().ofLong("list.long.notThere2")).isEmpty();
assertThat(data.list().of("someValues")).contains("13", "42", "55");
assertThat(data.list().of("someValues", "a", "b")).contains("13", "42", "55");
assertThat(data.list().of("list.notThere", "a", "b")).contains("a", "b");
assertThat(data.list().of("list.notThere2")).isEmpty();

assertThat(data.list().ofInt("someValues")).contains(13, 42, 55);
assertThat(data.list().ofInt("someValues", 22)).contains(13, 42, 55);
assertThat(data.list().ofInt("list.int.notThere", 51, 52)).contains(51, 52);
assertThat(data.list().ofInt("list.int.notThere2")).isEmpty();

assertThat(data.list().ofLong("someValues")).contains(13L, 42L, 55L);
assertThat(data.list().ofLong("someValues", 22L)).contains(13L, 42L, 55L);
assertThat(data.list().ofLong("list.long.notThere", 51L, 52L)).contains(51L, 52L);
assertThat(data.list().ofLong("list.long.notThere2")).isEmpty();
}

@Test
void getSet() {
assertThat(data.getSet().of("1someValues")).contains("13", "42", "55");
assertThat(data.getSet().of("1someValues", "a", "b")).contains("13", "42", "55");
assertThat(data.getSet().of("1set.notThere", "a", "b")).contains("a", "b");
assertThat(data.getSet().of("1set.notThere2")).isEmpty();

assertThat(data.getSet().ofInt("1someValues")).contains(13, 42, 55);
assertThat(data.getSet().ofInt("1someValues", 22)).contains(13, 42, 55);
assertThat(data.getSet().ofInt("1set.int.notThere", 51, 52)).contains(51, 52);
assertThat(data.getSet().ofInt("1set.int.notThere2")).isEmpty();

assertThat(data.getSet().ofLong("1someValues")).contains(13L, 42L, 55L);
assertThat(data.getSet().ofLong("1someValues", 22L)).contains(13L, 42L, 55L);
assertThat(data.getSet().ofLong("1set.long.notThere", 51L, 52L)).contains(51L, 52L);
assertThat(data.getSet().ofLong("1set.long.notThere2")).isEmpty();
assertThat(data.set().of("1someValues")).contains("13", "42", "55");
assertThat(data.set().of("1someValues", "a", "b")).contains("13", "42", "55");
assertThat(data.set().of("1set.notThere", "a", "b")).contains("a", "b");
assertThat(data.set().of("1set.notThere2")).isEmpty();

assertThat(data.set().ofInt("1someValues")).contains(13, 42, 55);
assertThat(data.set().ofInt("1someValues", 22)).contains(13, 42, 55);
assertThat(data.set().ofInt("1set.int.notThere", 51, 52)).contains(51, 52);
assertThat(data.set().ofInt("1set.int.notThere2")).isEmpty();

assertThat(data.set().ofLong("1someValues")).contains(13L, 42L, 55L);
assertThat(data.set().ofLong("1someValues", 22L)).contains(13L, 42L, 55L);
assertThat(data.set().ofLong("1set.long.notThere", 51L, 52L)).contains(51L, 52L);
assertThat(data.set().ofLong("1set.long.notThere2")).isEmpty();
}

enum MyEnum {
Expand Down

0 comments on commit 4413bcc

Please sign in to comment.