@Test public void getAsStringList_keyExists_returnsList() { cut = createJsonParser(KEY_2, STRING_LIST_VALUE); List<String> list = cut.getAsStringList(KEY_2); assertThat(list).hasSize(3); assertThat(list).first().isEqualTo("a"); }
@Override public List<String> getAsStringList(String name) { List<String> list = new ArrayList<>(); if (contains(name)) { if (getJsonObject().get(name) instanceof String) { list.add(getAsString(name)); } else { list = getAsList(name, String.class); } } return list; }
DefaultJsonObject implements JsonObject { @Override public List<String> getAsStringList(String name) { List<String> list = new ArrayList<>(); if (contains(name)) { if (getJsonObject().get(name) instanceof String) { list.add(getAsString(name)); } else { list = getAsList(name, String.class); } } return list; } }
DefaultJsonObject implements JsonObject { @Override public List<String> getAsStringList(String name) { List<String> list = new ArrayList<>(); if (contains(name)) { if (getJsonObject().get(name) instanceof String) { list.add(getAsString(name)); } else { list = getAsList(name, String.class); } } return list; } DefaultJsonObject(String jsonString); }
DefaultJsonObject implements JsonObject { @Override public List<String> getAsStringList(String name) { List<String> list = new ArrayList<>(); if (contains(name)) { if (getJsonObject().get(name) instanceof String) { list.add(getAsString(name)); } else { list = getAsList(name, String.class); } } return list; } DefaultJsonObject(String jsonString); @Override boolean contains(String key); @Override boolean isEmpty(); @Override List<T> getAsList(String name, Class<T> type); @Override List<String> getAsStringList(String name); @Override @Nullable String getAsString(String name); @Override @Nullable Instant getAsInstant(String name); @Nullable @Override Long getAsLong(String name); @Override @Nullable JsonObject getJsonObject(String name); @Override List<JsonObject> getJsonObjects(String name); @Override Map<String, String> getKeyValueMap(); @Override String asJsonString(); @Override String toString(); }
DefaultJsonObject implements JsonObject { @Override public List<String> getAsStringList(String name) { List<String> list = new ArrayList<>(); if (contains(name)) { if (getJsonObject().get(name) instanceof String) { list.add(getAsString(name)); } else { list = getAsList(name, String.class); } } return list; } DefaultJsonObject(String jsonString); @Override boolean contains(String key); @Override boolean isEmpty(); @Override List<T> getAsList(String name, Class<T> type); @Override List<String> getAsStringList(String name); @Override @Nullable String getAsString(String name); @Override @Nullable Instant getAsInstant(String name); @Nullable @Override Long getAsLong(String name); @Override @Nullable JsonObject getJsonObject(String name); @Override List<JsonObject> getJsonObjects(String name); @Override Map<String, String> getKeyValueMap(); @Override String asJsonString(); @Override String toString();  }