class ImmutablePayload implements Payload {

    @Override
    public JsonObject toJson() {
        final JsonObjectBuilder jsonObjectBuilder = JsonObject.newBuilder();
        jsonObjectBuilder.set(JsonFields.PATH, path.toString());

        if (null != value) {
            jsonObjectBuilder.set(JsonFields.VALUE, value);
        }
        if (null != extra) {
            jsonObjectBuilder.set(JsonFields.EXTRA, extra);
        }
        if (null != status) {
            jsonObjectBuilder.set(JsonFields.STATUS, status.toInt());
        }
        if (null != revision) {
            jsonObjectBuilder.set(JsonFields.REVISION, revision);
        }
        if (null != timestamp) {
            jsonObjectBuilder.set(JsonFields.TIMESTAMP, timestamp.toString());
        }
        if (null != metadata) {
            jsonObjectBuilder.set(JsonFields.METADATA, metadata.toJson());
        }
        if (null != fields) {
            jsonObjectBuilder.set(JsonFields.FIELDS, fields.toString());
        }

        return jsonObjectBuilder.build();
    }

    private  ImmutablePayload(final ImmutablePayloadBuilder builder);

}