ImmutableJsonObject extends AbstractJsonValue implements JsonObject { @Override public <T> JsonObject set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) { requireNonNull(fieldDefinition, "The JSON field definition to set the value for must not be null!"); final JsonPointer pointer = fieldDefinition.getPointer(); final JsonKey leafKey = pointer.getLeaf().orElseThrow(() -> { final String msgTemplate = "The pointer of the field definition <{0}> must not be empty!"; return new IllegalArgumentException(MessageFormat.format(msgTemplate, fieldDefinition)); }); final JsonField field = JsonField.newInstance(leafKey, JsonValue.of(value), fieldDefinition); return setFieldInHierarchy(this, pointer, field); } 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 orderOfFieldsDoesNotAffectEquality() { final JsonObjectBuilder barJsonObjectBuilder = JsonObject.newBuilder(); barJsonObjectBuilder.set("baz", KNOWN_INT_23); final JsonObjectBuilder fooJsonObjectLeftBuilder = JsonObject.newBuilder(); fooJsonObjectLeftBuilder.set("bar", barJsonObjectBuilder.build()); final int intValue10 = 10; fooJsonObjectLeftBuilder.set("yo", intValue10); final JsonObjectBuilder leftObjectBuilder = JsonObject.newBuilder(); leftObjectBuilder.set("foo", fooJsonObjectLeftBuilder.build()); final JsonObjectBuilder fooJsonObjectRightBuilder = JsonObject.newBuilder(); fooJsonObjectRightBuilder.set("yo", intValue10); fooJsonObjectRightBuilder.set("bar", barJsonObjectBuilder.build()); final JsonObjectBuilder rightObjectBuilder = JsonObject.newBuilder(); rightObjectBuilder.set("foo", fooJsonObjectRightBuilder.build()); final JsonObject leftJsonObject = leftObjectBuilder.build(); final JsonObject rightJsonObject = rightObjectBuilder.build(); assertThat(leftJsonObject).isEqualTo(rightJsonObject); }