ImmutableJsonObject extends AbstractJsonValue implements JsonObject { public static ImmutableJsonObject of(final Map<String, JsonField> fields) { return new ImmutableJsonObject(SoftReferencedFieldMap.of(fields)); } ImmutableJsonObject(final SoftReferencedFieldMap theFieldMap); static ImmutableJsonObject empty(); static ImmutableJsonObject of(final Map<String, JsonField> fields); static ImmutableJsonObject of(final Map<String, JsonField> fields,
            @Nullable final String stringRepresentation); static ImmutableJsonObject of(final Map<String, JsonField> fields,
            @Nullable final byte[] cborRepresentation); @Override JsonObject setValue(final CharSequence key, final int value); @Override JsonObject setValue(final CharSequence key, final long value); @Override JsonObject setValue(final CharSequence key, final double value); @Override JsonObject setValue(final CharSequence key, final boolean value); @Override JsonObject setValue(final CharSequence key, final String value); @Override JsonObject setValue(final CharSequence key, final JsonValue value); @Override JsonObject set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value); @Override ImmutableJsonObject set(final JsonField field); @Override JsonObject setAll(final Iterable<JsonField> fields); @Override boolean contains(final CharSequence key); @Override Optional<JsonValue> getValue(final CharSequence key); @Override Optional<T> getValue(final JsonFieldDefinition<T> fieldDefinition); @Override T getValueOrThrow(final JsonFieldDefinition<T> fieldDefinition); @Override JsonObject get(final JsonPointer pointer); @Override JsonObject get(final JsonFieldDefinition fieldDefinition); @Override JsonObject get(final JsonFieldSelector fieldSelector); @Override JsonObject remove(final CharSequence key); @Override List<JsonKey> getKeys(); @Override Optional<JsonField> getField(final CharSequence key); @Override boolean isObject(); @Override JsonObject asObject(); @Override Iterator<JsonField> iterator(); @Override Stream<JsonField> stream(); @Override boolean isEmpty(); @Override int getSize(); @SuppressWarnings({"checkstyle:com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck", "squid:MethodCyclomaticComplexity"}) @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 Map<String, JsonField> jsonFieldsRed = toMap("foo", JsonValue.of(1)); final Map<String, JsonField> jsonFieldsBlack = toMap("foo", JsonValue.of(2)); final ImmutableJsonObject.SoftReferencedFieldMap redFieldMap = ImmutableJsonObject.SoftReferencedFieldMap.of(jsonFieldsRed); final ImmutableJsonObject.SoftReferencedFieldMap blackFieldMap = ImmutableJsonObject.SoftReferencedFieldMap .of(jsonFieldsBlack); final ImmutableJsonObject redObject = ImmutableJsonObject.of(jsonFieldsRed); final ImmutableJsonObject blackObject = ImmutableJsonObject.of(jsonFieldsBlack); EqualsVerifier.forClass(ImmutableJsonObject.class) .withPrefabValues(ImmutableJsonObject.SoftReferencedFieldMap.class, redFieldMap, blackFieldMap) .withPrefabValues(ImmutableJsonObject.class, redObject, blackObject) .withNonnullFields("fieldMap") .verify(); }
@Test public void checkUnsupportedOperations() { final JsonValue underTest = ImmutableJsonObject.of(KNOWN_FIELDS); assertThat(underTest).doesNotSupport(JsonValue::asArray); 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); }