@Test public void testArr() { JsonArray array = arr().get(); assertNotNull("arr().get() results in non-null JsonArray", array); assertTrue("arr().get() results in empty JsonArray", !array.iterator().hasNext()); JsonArray nullArray = arr((Object[]) null).get(); assertNotNull("arr(null).get() results in non-null JsonArray", nullArray); assertTrue("arr(null).get() results in empty JsonArray", !nullArray.iterator().hasNext()); assertEquals("easy numerical sequence", "[0,1,2,3,4]", arr(0, 1, 2, 3, 4).get().toString()); assertEquals("easy numerical sequence as vals", "[0,1,2,3,4]", arr(val(0), val(1), val(2), val(3), val(4)).get().toString()); assertEquals("easy numerical sequence as dotted vals", "[0,1,2,3,4]", arr().val(0).val(1).val(2).val(3).val(4).get().toString()); assertEquals("easy numerical sequence as dotted vals, no arr() initiator", "[0,1,2,3,4]", val(0).val(1).val(2).val(3).val(4).get().toString()); assertEquals("numerical sequence as arr().and()", "[0,1,2,3,4]", arr(0, 1).and(2, 3, 4).get().toString()); assertEquals("arr().opt(null) should leave empty object", Json.createArrayBuilder().build(), arr().opt(null).get()); assertEquals("arr().opt(null, ifNotValue) should return with JsonObject.NULL when ifNotValue is provided", Json.createArrayBuilder().add(JsonValue.NULL).build(), arr().opt(null, "value").get()); assertEquals("arr().opt(obj()) should leave empty object", Json.createArrayBuilder().build(), arr().opt(obj()).get()); assertEquals("arr().opt(arr()) should leave empty object", Json.createArrayBuilder().build(), arr().opt(arr()).get()); assertEquals("arr().opt(JsonObject.NULL) should leave empty object", Json.createArrayBuilder().build(), arr().opt(JsonObject.NULL).get()); assertEquals("arr().opt(string) should return object with key", Json.createArrayBuilder().add("value").build(), arr().opt("value").get()); assertEquals("arr().opt(string, default) should return object with key", Json.createArrayBuilder().add("value").build(), arr().opt("value", "notValue").get()); assertEquals("arr().opt(string, ifNotValue) should return object with key when value is not ifNotValue", Json.createArrayBuilder().add("value").build(), arr().opt("value", "notValue").get()); assertEquals("arr().opt(string, ifNotValue) should return empty object when value is ifNotValue", Json.createArrayBuilder().build(), arr().opt("value", "value").get()); }
public static Arr arr(Object... values) { if (values != null) { return new Arr(Arrays.asList(values)); } else { return new Arr(Collections.emptyList()); } }
JavaxJson { public static Arr arr(Object... values) { if (values != null) { return new Arr(Arrays.asList(values)); } else { return new Arr(Collections.emptyList()); } } }
JavaxJson { public static Arr arr(Object... values) { if (values != null) { return new Arr(Arrays.asList(values)); } else { return new Arr(Collections.emptyList()); } } private  JavaxJson(); }
JavaxJson { public static Arr arr(Object... values) { if (values != null) { return new Arr(Arrays.asList(values)); } else { return new Arr(Collections.emptyList()); } } private  JavaxJson(); static boolean nonEmptyValue(final @Nullable JsonValue value); static boolean nonDefaultValue(final @Nullable JsonValue value, final @NotNull JsonValue defaultValue); static JsonValue wrap(final Object object); @SuppressWarnings("WeakerAccess") static Object unwrap(final JsonValue jsonValue); @SuppressWarnings("WeakerAccess") static Map<String, Object> unwrapObject(final JsonObject jsonObject); @SuppressWarnings("WeakerAccess") static List<Object> unwrapArray(final JsonArray jsonArray); static @NotNull JsonObject shallowMergeObjects(final @Nullable JsonObject base,
                                                          final @Nullable JsonObject overlay); static Value val(Object value); static Obj obj(final Key... keys); static Obj obj(final JsonObject jsonObject); static Obj obj(final Map<?, ?> map); static Key key(final String key, final Object value); static KeyCursor key(final String key); static Arr arr(Object... values); @SuppressWarnings("WeakerAccess") static Optional<JsonObject> optObject(final JsonObject json, final String key); @SuppressWarnings("WeakerAccess") static JsonObject objectOrEmpty(final JsonObject json, final String key); @SuppressWarnings("WeakerAccess") static Optional<JsonArray> optArray(final JsonObject json, final String key); static JsonArray arrayOrEmpty(final JsonObject json, final String key); static List<String> mapArrayOfStrings(final JsonArray jsonArray); static List<R> mapArrayOfStrings(final JsonArray jsonArray,
                                                final Function<String, R> mapFunction); static List<R> mapArrayOfStrings(final JsonArray jsonArray,
                                                final Function<String, R> mapFunction,
                                                final boolean discardNulls); static List<R> mapArrayOfObjects(final JsonArray jsonArray,
                                                final Function<JsonObject, R> mapFunction); static List<R> mapArrayOfObjects(final JsonArray jsonArray,
                                                final Function<JsonObject, R> mapFunction,
                                                final boolean discardNulls); static List<R> mapObjectValues(final JsonObject jsonObject,
                                              final BiFunction<String, JsonObject, R> mapBiFunction,
                                              final boolean discardNulls); @SuppressWarnings("WeakerAccess") static List<R> parseFromArray(final @NotNull JsonArray jsonArray,
                                             final @NotNull Fun.ThrowingFunction<String, R> parser,
                                             final @Nullable BiConsumer<String, Exception> errorConsumer); static boolean hasNonNull(final @NotNull JsonObject json, final String key); }
JavaxJson { public static Arr arr(Object... values) { if (values != null) { return new Arr(Arrays.asList(values)); } else { return new Arr(Collections.emptyList()); } } private  JavaxJson(); static boolean nonEmptyValue(final @Nullable JsonValue value); static boolean nonDefaultValue(final @Nullable JsonValue value, final @NotNull JsonValue defaultValue); static JsonValue wrap(final Object object); @SuppressWarnings("WeakerAccess") static Object unwrap(final JsonValue jsonValue); @SuppressWarnings("WeakerAccess") static Map<String, Object> unwrapObject(final JsonObject jsonObject); @SuppressWarnings("WeakerAccess") static List<Object> unwrapArray(final JsonArray jsonArray); static @NotNull JsonObject shallowMergeObjects(final @Nullable JsonObject base,
                                                          final @Nullable JsonObject overlay); static Value val(Object value); static Obj obj(final Key... keys); static Obj obj(final JsonObject jsonObject); static Obj obj(final Map<?, ?> map); static Key key(final String key, final Object value); static KeyCursor key(final String key); static Arr arr(Object... values); @SuppressWarnings("WeakerAccess") static Optional<JsonObject> optObject(final JsonObject json, final String key); @SuppressWarnings("WeakerAccess") static JsonObject objectOrEmpty(final JsonObject json, final String key); @SuppressWarnings("WeakerAccess") static Optional<JsonArray> optArray(final JsonObject json, final String key); static JsonArray arrayOrEmpty(final JsonObject json, final String key); static List<String> mapArrayOfStrings(final JsonArray jsonArray); static List<R> mapArrayOfStrings(final JsonArray jsonArray,
                                                final Function<String, R> mapFunction); static List<R> mapArrayOfStrings(final JsonArray jsonArray,
                                                final Function<String, R> mapFunction,
                                                final boolean discardNulls); static List<R> mapArrayOfObjects(final JsonArray jsonArray,
                                                final Function<JsonObject, R> mapFunction); static List<R> mapArrayOfObjects(final JsonArray jsonArray,
                                                final Function<JsonObject, R> mapFunction,
                                                final boolean discardNulls); static List<R> mapObjectValues(final JsonObject jsonObject,
                                              final BiFunction<String, JsonObject, R> mapBiFunction,
                                              final boolean discardNulls); @SuppressWarnings("WeakerAccess") static List<R> parseFromArray(final @NotNull JsonArray jsonArray,
                                             final @NotNull Fun.ThrowingFunction<String, R> parser,
                                             final @Nullable BiConsumer<String, Exception> errorConsumer); static boolean hasNonNull(final @NotNull JsonObject json, final String key); @SuppressWarnings("WeakerAccess")
    static final Function<JsonValue, String> JSON_VALUE_STRING; }