/** * Copy the current immutable object by setting a value for the {@link ImmutablesTest.Train#observationCar() observationCar} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for observationCar * @return A modified copy of the {@code this} object */ public final ImmutableTrain withObservationCar(boolean value) { if (this.observationCar == value) return this; return new ImmutableTrain(this.name, this.carriages, value); }
/** * Copy the current immutable object by setting a value for the {@link ImmutablesTest.Train#carriages() carriages} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for carriages * @return A modified copy of the {@code this} object */ public final ImmutableTrain withCarriages(int value) { if (this.carriages == value) return this; return new ImmutableTrain(this.name, value, this.observationCar); }
/** * Copy the current immutable object by setting a value for the {@link ImmutablesTest.Train#name() 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 ImmutableTrain withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableTrain(newValue, this.carriages, this.observationCar); }
/** * Builds a new {@link ImmutableTrain ImmutableTrain}. * @return An immutable instance of Train * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableTrain build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableTrain(name, carriages, observationCar); }