/** * Copy the current immutable object by setting a value for the {@link ImmutablesTest.FooBarBaz#id() id} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for id * @return A modified copy of the {@code this} object */ public final ImmutableFooBarBaz withId(int value) { if (this.id == value) return this; return new ImmutableFooBarBaz(value, this.foo, this.bar, this.baz); }
/** * This instance is equal to all instances of {@code ImmutableFooBarBaz} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableFooBarBaz && equalTo((ImmutableFooBarBaz) another); }
/** * Converts to {@link ImmutableFooBarBaz ImmutableFooBarBaz}. * @return An immutable instance of FooBarBaz */ public final ImmutableFooBarBaz toImmutable() { checkRequiredAttributes(); return ImmutableFooBarBaz.copyOf(this); }
/** * Creates an immutable copy of a {@link ImmutablesTest.FooBarBaz} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable FooBarBaz instance */ public static ImmutableFooBarBaz copyOf(ImmutablesTest.FooBarBaz instance) { if (instance instanceof ImmutableFooBarBaz) { return (ImmutableFooBarBaz) instance; } return ImmutableFooBarBaz.builder() .from(instance) .build(); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link ImmutablesTest.FooBarBaz#bar() bar} attribute. * @param value The value for bar * @return A modified copy of {@code this} object */ public final ImmutableFooBarBaz withBar(int value) { @Nullable Integer newValue = value; if (Objects.equals(this.bar, newValue)) return this; return new ImmutableFooBarBaz(this.id, this.foo, newValue, this.baz); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link ImmutablesTest.FooBarBaz#baz() baz} attribute. * @param value The value for baz * @return A modified copy of {@code this} object */ public final ImmutableFooBarBaz withBaz(double value) { @Nullable Double newValue = value; if (Objects.equals(this.baz, newValue)) return this; return new ImmutableFooBarBaz(this.id, this.foo, this.bar, newValue); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link ImmutablesTest.FooBarBaz#foo() foo} attribute. * @param value The value for foo * @return A modified copy of {@code this} object */ public final ImmutableFooBarBaz withFoo(String value) { @Nullable String newValue = Objects.requireNonNull(value, "foo"); if (Objects.equals(this.foo, newValue)) return this; return new ImmutableFooBarBaz(this.id, newValue, this.bar, this.baz); }
/** * Copy the current immutable object by setting an optional value for the {@link ImmutablesTest.FooBarBaz#foo() foo} 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 foo * @return A modified copy of {@code this} object */ public final ImmutableFooBarBaz withFoo(Optional<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.foo, value)) return this; return new ImmutableFooBarBaz(this.id, value, this.bar, this.baz); }
/** * Copy the current immutable object by setting an optional value for the {@link ImmutablesTest.FooBarBaz#bar() bar} 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 bar * @return A modified copy of {@code this} object */ public final ImmutableFooBarBaz withBar(OptionalInt optional) { @Nullable Integer value = optional.isPresent() ? optional.getAsInt() : null; if (Objects.equals(this.bar, value)) return this; return new ImmutableFooBarBaz(this.id, this.foo, value, this.baz); }
/** * Copy the current immutable object by setting an optional value for the {@link ImmutablesTest.FooBarBaz#baz() baz} 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 baz * @return A modified copy of {@code this} object */ public final ImmutableFooBarBaz withBaz(OptionalDouble optional) { @Nullable Double value = optional.isPresent() ? optional.getAsDouble() : null; if (Objects.equals(this.baz, value)) return this; return new ImmutableFooBarBaz(this.id, this.foo, this.bar, value); }
/** * Builds a new {@link ImmutableFooBarBaz ImmutableFooBarBaz}. * @return An immutable instance of FooBarBaz * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableFooBarBaz build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableFooBarBaz(id, foo, bar, baz); }