ImmutableJsonArray extends AbstractJsonValue implements JsonArray { public static ImmutableJsonArray of(final List<JsonValue> values) { return new ImmutableJsonArray(SoftReferencedValueList.of(values)); } ImmutableJsonArray(final SoftReferencedValueList theValueList); static ImmutableJsonArray empty(); static ImmutableJsonArray of(final List<JsonValue> values); static ImmutableJsonArray of(final List<JsonValue> values, @Nullable final String stringRepresentation); static ImmutableJsonArray of(final List<JsonValue> values, @Nullable final byte[] cborRepresentation); static ImmutableJsonArray of(final List<JsonValue> values, @Nullable final String stringRepresentation,
            @Nullable final byte[] cborRepresentation); @Override boolean isArray(); @Override ImmutableJsonArray asArray(); @Override ImmutableJsonArray add(final int value, final int... furtherValues); @Override ImmutableJsonArray add(final long value, final long... furtherValues); @Override ImmutableJsonArray add(final double value, final double... furtherValues); @Override ImmutableJsonArray add(final boolean value, final boolean... furtherValues); @Override ImmutableJsonArray add(final String value, final String... furtherValues); @Override ImmutableJsonArray add(final JsonValue value, final JsonValue... furtherValues); @Override Optional<JsonValue> get(final int index); @Override boolean isEmpty(); @Override int getSize(); @Override boolean contains(final JsonValue value); @Override int indexOf(final JsonValue value); @Override Iterator<JsonValue> iterator(); @Override Stream<JsonValue> stream(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Override void writeValue(final SerializationContext serializationContext); @Override long getUpperBoundForStringSize();  }
@Test public void testHashCodeAndEquals() { final List<JsonValue> stringJsonValueList = toList(JsonValue.of("foo"), JsonValue.of("bar")); final List<JsonValue> numberJsonValueList = toList(JsonValue.of(1), JsonValue.of(2), JsonValue.of(3)); final ImmutableJsonArray redArray = ImmutableJsonArray.of(stringJsonValueList); final ImmutableJsonArray blackArray = ImmutableJsonArray.of(numberJsonValueList); final ImmutableJsonArray.SoftReferencedValueList redValueList = ImmutableJsonArray.SoftReferencedValueList.of(stringJsonValueList); final ImmutableJsonArray.SoftReferencedValueList blackValueList = ImmutableJsonArray.SoftReferencedValueList.of(numberJsonValueList); EqualsVerifier.forClass(ImmutableJsonArray.class) .withPrefabValues(ImmutableJsonArray.class, redArray, blackArray) .withPrefabValues(ImmutableJsonArray.SoftReferencedValueList.class, redValueList, blackValueList) .withNonnullFields("valueList") .verify(); }
@Test public void getSizeReturnsExpected() { final ImmutableJsonArray underTest = ImmutableJsonArray.of(KNOWN_INT_VALUE_LIST); assertThat(underTest).hasSize(3); }
@Test public void checkUnsupportedOperations() { final ImmutableJsonArray underTest = ImmutableJsonArray.of(KNOWN_INT_VALUE_LIST); assertThat(underTest).doesNotSupport(JsonValue::asObject); assertThat(underTest).doesNotSupport(JsonValue::asBoolean); assertThat(underTest).doesNotSupport(JsonValue::asString); assertThat(underTest).doesNotSupport(JsonValue::asInt); assertThat(underTest).doesNotSupport(JsonValue::asLong); assertThat(underTest).doesNotSupport(JsonValue::asDouble); }