ImmutableLogEntry implements LogEntry { @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { final JsonObjectBuilder builder = JsonFactory.newObjectBuilder() .set(JsonFields.CORRELATION_ID, correlationId) .set(JsonFields.TIMESTAMP, timestamp.toString()) .set(JsonFields.CATEGORY, logCategory.getName()) .set(JsonFields.TYPE, logType.getType()) .set(JsonFields.LEVEL, logLevel.getLevel()) .set(JsonFields.MESSAGE, message); if (null != address) { builder.set(JsonFields.ADDRESS, address); } if (null != thingId) { builder.set(JsonFields.THING_ID, thingId.toString()); } return builder.build(); } private  ImmutableLogEntry(final Builder builder); static LogEntryBuilder getBuilder(final String correlationId, final Instant timestamp, final LogCategory logCategory,
            final LogType logType, final LogLevel logLevel, final String message); static LogEntryBuilder getBuilder(final String correlationId, final Instant timestamp, final LogCategory logCategory,
            final LogType logType, final LogLevel logLevel, final String message,
            @Nullable final String address, @Nullable final ThingId thingId); static LogEntry fromJson(final JsonObject jsonObject); @Override String getCorrelationId(); @Override Instant getTimestamp(); @Override LogCategory getLogCategory(); @Override LogType getLogType(); @Override LogLevel getLogLevel(); @Override String getMessage(); @Override Optional<String> getAddress(); @Override Optional<ThingId> getThingId(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toJsonReturnsExpected() { final JsonObject actual = LOG_ENTRY.toJson(); assertThat(actual).isEqualTo(LOG_ENTRY_JSON); }