ImmutableResourceStatus implements ResourceStatus { @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); jsonObjectBuilder.set(JsonFields.TYPE, type.getName(), predicate); jsonObjectBuilder.set(JsonFields.CLIENT, client, predicate); if (address != null) { jsonObjectBuilder.set(JsonFields.ADDRESS, address, predicate); } jsonObjectBuilder.set(JsonFields.SCHEMA_VERSION, schemaVersion.toInt(), predicate); jsonObjectBuilder.set(JsonFields.STATUS, status.getName(), predicate); if (statusDetails != null) { jsonObjectBuilder.set(JsonFields.STATUS_DETAILS, statusDetails, predicate); } if (inStateSince != null) { jsonObjectBuilder.set(JsonFields.IN_STATE_SINCE, inStateSince.toString(), predicate); } return jsonObjectBuilder.build(); } private  ImmutableResourceStatus(final ResourceType type, final String client, final ConnectivityStatus status,
            @Nullable final String address,
            @Nullable final String statusDetails,
            @Nullable final Instant inStateSince); static ImmutableResourceStatus of(final ResourceType type, final String client,
            final ConnectivityStatus status,
            @Nullable final String address,
            @Nullable final String statusDetails,
            @Nullable final Instant inStateSince); static ImmutableResourceStatus of(final ResourceType type, final String client,
            final ConnectivityStatus status,
            @Nullable final String address,
            @Nullable final String statusDetails); @Override ResourceType getResourceType(); @Override String getClient(); @Override Optional<String> getAddress(); @Override ConnectivityStatus getStatus(); @Override Optional<String> getStatusDetails(); @Override Optional<Instant> getInStateSince(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate); static ResourceStatus fromJson(final JsonObject jsonObject); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toJsonReturnsExpected() { final JsonObject actual = RESOURCE_STATUS.toJson(); assertThat(actual).isEqualTo(RESOURCE_STATUS_JSON); }