/** * Copy the current immutable object by setting a value for the {@link Server#getHost() host} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for host * @return A modified copy of the {@code this} object */ public final ImmutableServer withHost(String value) { if (this.host.equals(value)) return this; String newValue = Objects.requireNonNull(value, "host"); return new ImmutableServer(this.name, newValue, this.port, this.scheme); }
/** * Copy the current immutable object by setting a value for the {@link Server#getName() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name * @return A modified copy of the {@code this} object */ public final ImmutableServer withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableServer(newValue, this.host, this.port, this.scheme); }
/** * Copy the current immutable object by setting a value for the {@link Server#getPort() port} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for port * @return A modified copy of the {@code this} object */ public final ImmutableServer withPort(String value) { if (this.port.equals(value)) return this; String newValue = Objects.requireNonNull(value, "port"); return new ImmutableServer(this.name, this.host, newValue, this.scheme); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link Server#getScheme() scheme} attribute. * @param value The value for scheme * @return A modified copy of {@code this} object */ public final ImmutableServer withScheme(String value) { @Nullable String newValue = Objects.requireNonNull(value, "scheme"); if (Objects.equals(this.scheme, newValue)) return this; return new ImmutableServer(this.name, this.host, this.port, newValue); }
/** * Copy the current immutable object by setting an optional value for the {@link Server#getScheme() scheme} 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 scheme * @return A modified copy of {@code this} object */ public final ImmutableServer withScheme(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.scheme, value)) return this; return new ImmutableServer(this.name, this.host, this.port, value); }
/** * Builds a new {@link ImmutableServer ImmutableServer}. * @return An immutable instance of Server * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableServer build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableServer(name, host, port, scheme); }