/** * The final message body will be a direct reference to the message * body, the MessageProperties will be a shallow copy. * @param message The message. * @return The builder. */ public static MessageBuilder fromMessage(Message message) { Assert.notNull(message, MESSAGE_CANNOT_BE_NULL); return new MessageBuilder(message); }
/** * The final message body will be a direct reference to 'body'. * @param body The body. * @return The builder. */ public static MessageBuilder withBody(byte[] body) { Assert.notNull(body, BODY_CANNOT_BE_NULL); return new MessageBuilder(body); }
/** * The final message body will be a copy of 'body' in a new array. * @param body The body. * @return The builder. */ public static MessageBuilder withClonedBody(byte[] body) { Assert.notNull(body, BODY_CANNOT_BE_NULL); return new MessageBuilder(Arrays.copyOf(body, body.length)); }
/** * The final message body will be a new array containing the byte range from * 'body'. * @param body The body. * @param from The starting index. * @param to The ending index. * @return The builder. * * @see Arrays#copyOfRange(byte[], int, int) */ public static MessageBuilder withBody(byte[] body, int from, int to) { Assert.notNull(body, BODY_CANNOT_BE_NULL); return new MessageBuilder(Arrays.copyOfRange(body, from, to)); }
/** * The final message will have a copy of the message * body, the MessageProperties will be cloned (top level only). * @param message The message. * @return The builder. */ public static MessageBuilder fromClonedMessage(Message message) { Assert.notNull(message, MESSAGE_CANNOT_BE_NULL); byte[] body = message.getBody(); Assert.notNull(body, BODY_CANNOT_BE_NULL); return new MessageBuilder(Arrays.copyOf(body, body.length), message.getMessageProperties()); }