@Override default MessageHeadersBuilder toBuilder() { return MessageHeadersBuilder.of(this); }
/** * Returns a new builder for {@link MessageHeaders}. * * @return the builder. * @throws NullPointerException if {@code initialHeaders} is {@code null}. * @throws IllegalArgumentException if {@code initialHeaders} contains a value that did not represent its * appropriate Java type or if {@code initialHeaders} did lack a mandatory header. * @throws SubjectInvalidException if {@code initialHeaders} contains an invalid value for * {@link MessageHeaderDefinition#SUBJECT}. */ public static MessageHeadersBuilder newHeadersBuilder(final Map<String, String> initialHeaders) { return MessageHeadersBuilder.of(initialHeaders); }
/** * Returns a new instance of {@code MessageDirection} which is based on the specified map. * * @param headers the header key-value-pairs. * @return the instance. * @throws NullPointerException if {@code headers} is {@code null}. * @throws IllegalArgumentException if {@code headers} contains a value that did not represent its appropriate Java * type or if {@code headers} did lack a mandatory header. * @throws SubjectInvalidException if {@code headers} contains an invalid value for * {@link MessageHeaderDefinition#SUBJECT}. */ static MessageHeaders of(final Map<String, String> headers) { return MessageHeadersBuilder.of(headers).build(); }
/** * Returns a new instance of {@code MessageHeaders} which is based on the specified JSON object. * * @param jsonObject the JSON object representation of message headers. * @return the instance. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} contains a value that did not represent its appropriate * Java type or if {@code jsonObject} did lack a mandatory header. * @throws SubjectInvalidException if {@code jsonObject} contains an invalid value for * {@link MessageHeaderDefinition#SUBJECT}. */ static MessageHeaders of(final JsonObject jsonObject) { return MessageHeadersBuilder.of(jsonObject).build(); }
/** * Returns a new instance of {@code MessageHeadersBuilder} initialized with the the properties of the given {@code * jsonObject}. * * @param jsonObject the JSON object which provides the initial properties of the builder. * @return a builder for creating {@code MessageHeaders} object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} contains a value that did not represent its appropriate * Java type or if {@code jsonObject} did lack a mandatory header. * @throws SubjectInvalidException if {@code jsonObject} contains an invalid value for * {@link MessageHeaderDefinition#SUBJECT}. */ public static MessageHeadersBuilder of(final JsonObject jsonObject) { return of(toMap(jsonObject)); }
/** * Returns a new instance of {@code MessageHeadersBuilder}. * * @param direction the direction of the message. * @param thingId the thing ID of the message. * @param subject the subject of the message. * @return the instance. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code thingId} or {@code subject} is empty. * @throws SubjectInvalidException if {@code subject} is invalid. */ public static MessageHeadersBuilder newInstance(final MessageDirection direction, final CharSequence thingId, final CharSequence subject) { checkNotNull(direction, MessageHeaderDefinition.DIRECTION.getKey()); argumentNotEmpty(thingId, MessageHeaderDefinition.THING_ID.getKey()); argumentNotEmpty(subject, MessageHeaderDefinition.SUBJECT.getKey()); final Map<String, String> initialHeaders = new HashMap<>(); initialHeaders.put(MessageHeaderDefinition.DIRECTION.getKey(), direction.toString()); initialHeaders.put(MessageHeaderDefinition.THING_ID.getKey(), thingId.toString()); initialHeaders.put(MessageHeaderDefinition.SUBJECT.getKey(), subject.toString()); return of(initialHeaders); }