/** * Create a builder for a new {@link Message} instance with the provided payload. * * @param payload the payload for the new message */ public static <T> MessageBuilder<T> withPayload(T payload) { MessageBuilder<T> builder = new MessageBuilder<T>(payload, null); return builder; }
/** * Create a builder for a new {@link Message} instance pre-populated with * all of the headers copied from the provided message. The payload of the * provided Message will also be used as the payload for the new message. * * @param messageToCopy the Message from which the payload and all headers * will be copied */ public static <T> MessageBuilder<T> fromMessage(Message<T> message) { Assert.notNull(message, "message must not be null"); MessageBuilder<T> builder = new MessageBuilder<T>(message.getPayload(), message); return builder; }