/** * Fill a builder with attribute values from the provided {@code EventMessage} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder createFrom(EventMessage instance) { Objects.requireNonNull(instance, "instance"); Optional<String> eventOptional = instance.getEvent(); if (eventOptional.isPresent()) { event(eventOptional); } Optional<Object> dataOptional = instance.getData(); if (dataOptional.isPresent()) { data(dataOptional); } return this; }
static EventMessage of(String event, Object data) { return ImmutableEventMessage.builder().event(event).data(data).build(); }