/** * Returns a new JSON array which is based on the given JSON array of the Minimal Json project library. * * @param values the values to base the JSON array to be created on. * @return a new JSON array. * @throws NullPointerException if {@code minimalJsonArray} is {@code null}. */ public static ImmutableJsonArray of(final List<JsonValue> values) { return new ImmutableJsonArray(values); }
/** * Returns a new empty JSON array. * * @return a new empty JSON array. */ public static ImmutableJsonArray empty() { return new ImmutableJsonArray(Collections.emptyList()); }
/** * Returns a new JSON array which is based on the given JSON array of the Minimal Json project library. * * @param values the values to base the JSON array to be created on. * @param stringRepresentation the already known string representation of the returned array or {@code null}. * @return a new JSON array. * @throws NullPointerException if {@code values} is {@code null}. */ public static ImmutableJsonArray of(final List<JsonValue> values, @Nullable final String stringRepresentation) { requireNonNull(values, "The values of the JSON array must not be null!"); return new ImmutableJsonArray(SoftReferencedValueList.of(values, stringRepresentation)); }
/** * Returns a new empty JSON array. * * @return a new empty JSON array. */ public static ImmutableJsonArray empty() { ImmutableJsonArray result = emptyInstance; if (null == result) { result = new ImmutableJsonArray(SoftReferencedValueList.empty()); emptyInstance = result; } return result; }
@Override public ImmutableJsonArray add(final JsonValue value, final JsonValue... furtherValues) { checkValue(value); checkFurtherValues(furtherValues); SoftReferencedValueList extendedValueList = valueList.add(value); for (final JsonValue furtherValue : furtherValues) { extendedValueList = extendedValueList.add(furtherValue); } return new ImmutableJsonArray(extendedValueList); }
@Override public ImmutableJsonArray add(final boolean value, final boolean... furtherValues) { checkFurtherValues(furtherValues); SoftReferencedValueList extendedValueList = valueList.add(JsonValue.of(value)); for (final boolean furtherValue : furtherValues) { extendedValueList = extendedValueList.add(JsonValue.of(furtherValue)); } return new ImmutableJsonArray(extendedValueList); }