class 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);

}