/** * Sets the ID of the {@code Feature} from/to which the message will be sent. * * @param featureId the ID of the Feature from/to which the Message will be sent. * @return this builder to allow method chaining. * @throws IllegalArgumentException if {@code featureId} is empty. */ public MessageHeadersBuilder featureId(@Nullable final CharSequence featureId) { putCharSequence(MessageHeaderDefinition.FEATURE_ID, featureId); return myself; }
/** * Sets the MIME contentType of the payload of the Message. * * @param contentType the MIME contentType of the payload of the message. * @return this builder to allow method chaining. * @throws IllegalArgumentException if {@code contentType} is empty. */ public MessageHeadersBuilder contentType(@Nullable final CharSequence contentType) { putCharSequence(DittoHeaderDefinition.CONTENT_TYPE, contentType); return myself; }
/** * Sets the timeout of the Message to build. * * @param timeout the duration of the Message to time out. * @return this builder to allow method chaining. */ public MessageHeadersBuilder timeout(@Nullable final Duration timeout) { final MessageHeaderDefinition definition = MessageHeaderDefinition.TIMEOUT; if (null != timeout) { putCharSequence(definition, String.valueOf(timeout.getSeconds())); } else { removeHeader(definition.getKey()); } return myself; }
/** * Sets the specified URL which is used for message validation. * * @param validationUrl the validation URL to be set. * @return this builder to allow method chaining. * @throws IllegalArgumentException if {@code validationUrl} is empty. */ public MessageHeadersBuilder validationUrl(@Nullable final CharSequence validationUrl) { final MessageHeaderDefinition definition = MessageHeaderDefinition.VALIDATION_URL; if (null != validationUrl) { putCharSequence(definition, validationUrl); } else { removeHeader(definition.getKey()); } return myself; }
/** * Sets the status code of the Message to build. * * @param statusCode the status code. * @return this builder to allow method chaining. */ public MessageHeadersBuilder statusCode(@Nullable final HttpStatusCode statusCode) { final MessageHeaderDefinition definition = MessageHeaderDefinition.STATUS_CODE; if (null != statusCode) { putCharSequence(definition, String.valueOf(statusCode.toInt())); } else { removeHeader(definition.getKey()); } return myself; }
/** * Sets the timestamp of the Message to build. * * @param timestamp the timestamp of the message. * @return this builder to allow method chaining. */ public MessageHeadersBuilder timestamp(@Nullable final OffsetDateTime timestamp) { final MessageHeaderDefinition definition = MessageHeaderDefinition.TIMESTAMP; if (null != timestamp) { putCharSequence(definition, timestamp.toString()); } else { removeHeader(definition.getKey()); } return myself; }