/** * Copy the current immutable object by setting an optional value for the {@link Split#getLanguage() language} 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 language * @return A modified copy of {@code this} object */ public final ImmutableSplit withLanguage(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.language, value)) return this; return validate(new ImmutableSplit(this, value, this.expression)); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Split#getExpression() expression} attribute. * @param value The value for expression * @return A modified copy of {@code this} object */ public final ImmutableSplit withExpression(String value) { @Nullable String newValue = Objects.requireNonNull(value, "expression"); if (Objects.equals(this.expression, newValue)) return this; return validate(new ImmutableSplit(this, this.language, newValue)); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Split#getLanguage() language} attribute. * @param value The value for language * @return A modified copy of {@code this} object */ public final ImmutableSplit withLanguage(String value) { @Nullable String newValue = Objects.requireNonNull(value, "language"); if (Objects.equals(this.language, newValue)) return this; return validate(new ImmutableSplit(this, newValue, this.expression)); }
/** * Copy the current immutable object by setting an optional value for the {@link Split#getExpression() expression} 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 expression * @return A modified copy of {@code this} object */ public final ImmutableSplit withExpression(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.expression, value)) return this; return validate(new ImmutableSplit(this, this.language, value)); }
/** * Construct a new immutable {@code Split} instance. * @param language The value for the {@code language} attribute * @param expression The value for the {@code expression} attribute * @return An immutable Split instance */ public static Split of(Optional<String> language, Optional<String> expression) { return validate(new ImmutableSplit(language, expression)); }