private Object readResolve() throws ObjectStreamException { return validate(this); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link EventMessage#getEvent() event} attribute. * @param value The value for event * @return A modified copy of {@code this} object */ public final ImmutableEventMessage withEvent(String value) { @Nullable String newValue = Objects.requireNonNull(value, "event"); if (Objects.equals(this.event, newValue)) return this; return validate(new ImmutableEventMessage(this, newValue, this.data)); }
/** * Copy the current immutable object by setting an optional value for the {@link EventMessage#getEvent() event} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for event * @return A modified copy of {@code this} object */ public final ImmutableEventMessage withEvent(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.event, value)) return this; return validate(new ImmutableEventMessage(this, value, this.data)); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link EventMessage#getData() data} attribute. * @param value The value for data * @return A modified copy of {@code this} object */ public final ImmutableEventMessage withData(Object value) { @Nullable Object newValue = Objects.requireNonNull(value, "data"); if (this.data == newValue) return this; return validate(new ImmutableEventMessage(this, this.event, newValue)); }
/** * Copy the current immutable object by setting an optional value for the {@link EventMessage#getData() data} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for data * @return A modified copy of {@code this} object */ public final ImmutableEventMessage withData(Optional<? extends Object> optional) { @Nullable Object value = optional.orElse(null); if (this.data == value) return this; return validate(new ImmutableEventMessage(this, this.event, value)); }
/** * Construct a new immutable {@code EventMessage} instance. * @param event The value for the {@code event} attribute * @param data The value for the {@code data} attribute * @return An immutable EventMessage instance */ public static EventMessage of(Optional<String> event, Optional<Object> data) { return validate(new ImmutableEventMessage(event, data)); }