class ImmutableResourceStatus implements ResourceStatus {

    public static ResourceStatus fromJson(final JsonObject jsonObject) {
        final ResourceType readType = ResourceType.forName(
                jsonObject.getValueOrThrow(JsonFields.TYPE)).orElse(ResourceType.UNKNOWN);
        final String readClient = jsonObject.getValueOrThrow(JsonFields.CLIENT);
        final ConnectivityStatus readConnectionStatus = ConnectivityStatus.forName(
                jsonObject.getValueOrThrow(JsonFields.STATUS)).orElse(ConnectivityStatus.UNKNOWN);
        final String readAddress = jsonObject.getValue(JsonFields.ADDRESS).orElse(null);
        final String readConnectionStatusDetails = jsonObject.getValue(JsonFields.STATUS_DETAILS).orElse(null);
        final Instant readInStateSince =
                jsonObject.getValue(JsonFields.IN_STATE_SINCE).map(Instant::parse).orElse(null);
        return ImmutableResourceStatus.of(readType, readClient, readConnectionStatus, readAddress,
                readConnectionStatusDetails, readInStateSince);
    }

    private  ImmutableResourceStatus(final ResourceType type, final String client, final ConnectivityStatus status,
            @Nullable final String address,
            @Nullable final String statusDetails,
            @Nullable final Instant inStateSince);

}