/** * Fill this modifiable instance with attribute values from the provided {@link ImmutablesTest.FooBarBaz} instance. * Regular attribute values will be overridden, i.e. replaced with ones of an instance. * Any of the instance's absent optional values will not be copied (will not override current values). * @param instance The instance from which to copy values * @return {@code this} for use in a chained invocation */ public ModifiableFooBarBaz from(ImmutablesTest.FooBarBaz instance) { Objects.requireNonNull(instance, "instance"); setId(instance.id()); Optional<String> fooOptional = instance.foo(); if (fooOptional.isPresent()) { setFoo(fooOptional); } OptionalInt barOptional = instance.bar(); if (barOptional.isPresent()) { setBar(barOptional); } OptionalDouble bazOptional = instance.baz(); if (bazOptional.isPresent()) { setBaz(bazOptional); } return this; }