/** * Deserialize from a JSON object. * * @param jsonObject the JSON object to deserialize. * @param dittoHeaders the headers. * @return an instance of this class. * @throws NullPointerException if any argument is {@code null}. */ public static MessagePayloadSizeTooLargeException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new Builder() .loadJson(jsonObject) .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DEFAULT_DESCRIPTION)) .href(readHRef(jsonObject).orElse(null)) .build(); }
private Builder(final long actualBytes, final long maxBytes) { this(); message(MessageFormat.format(MESSAGE_TEMPLATE, actualBytes / 1024.0, maxBytes / 1024.0)); }
private Builder() { description(DEFAULT_DESCRIPTION); }
@Override protected MessagePayloadSizeTooLargeException newInvalidSizeException(final long maxSize, final long actualSize, final DittoHeaders headers) { return MessagePayloadSizeTooLargeException.newBuilder(actualSize, maxSize).dittoHeaders(headers).build(); }
/** * A mutable builder for a {@code MessagePayloadSizeTooLargeException}. * * @param actualBytes the actual amount of bytes which were too much (gt {@code maxBytes}) * @param maxBytes the maximal allowed amount of bytes * @return the builder. */ public static Builder newBuilder(final long actualBytes, final long maxBytes) { return new Builder(actualBytes, maxBytes); }
@Override protected MessagePayloadSizeTooLargeException newInvalidSizeException(final long maxSize, final long actualSize, final DittoHeaders headers) { return MessagePayloadSizeTooLargeException.newBuilder(actualSize, maxSize).dittoHeaders(headers).build(); }