class ImmutableLogEntry implements LogEntry {

    public static LogEntry fromJson(final JsonObject jsonObject) {
        final String correlationId = jsonObject.getValueOrThrow(JsonFields.CORRELATION_ID);
        final Instant timestamp = getTimestampOrThrow(jsonObject.getValueOrThrow(JsonFields.TIMESTAMP));
        final LogCategory category = getLogCategoryOrThrow(jsonObject);
        final LogType type = getLogTypeOrThrow(jsonObject);
        final LogLevel level = getLogLevelOrThrow(jsonObject);
        final String message = jsonObject.getValueOrThrow(JsonFields.MESSAGE);
        final String address = jsonObject.getValue(JsonFields.ADDRESS).orElse(null);
        final ThingId thingId = jsonObject.getValue(JsonFields.THING_ID).map(ThingId::of).orElse(null);

        return getBuilder(correlationId, timestamp, category, type, level, message, address, thingId)
                .build();
    }

    private  ImmutableLogEntry(final Builder builder);

}