--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombok+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package com.alex.example.lombok
import lombok.Builder;
import lombok.Data;
import lombok.NonNull;
@Data @Builder(toBuilder = true)
public class PostalCode {
@NonNull private final String province;
@NonNull private final String postalCode;
}
package com.alex.example.lombok;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class PostalCodeTest {
@Test
public void build_new_instance_in_the_same_package() {
final PostalCode postalCode = new PostalCode("province", "pc");
assertEquals("province", postalCode.getProvince());
assertEquals("pc", postalCode.getPostalCode());
}
@Test
public void build_with_builder() {
final PostalCode postalCode = PostalCode.builder().province("province").postalCode("pc").build();
assertEquals("province", postalCode.getProvince());
assertEquals("pc", postalCode.getPostalCode());
}
@Test
public void clone_with_builder() {
final PostalCode postalCode = PostalCode.builder().province("province").postalCode("pc").build();
final PostalCode cloned = postalCode.toBuilder().province("another province").build();
assertEquals("another province", cloned.getProvince());
assertEquals("pc", cloned.getPostalCode());
}
}
PostalCode.builder(original).province("another value").build()PostalCode.builder().clone(original).province("another value").build()To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
Anyway I don't understand why is necessary the @Wither if the builder exists.
--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombok+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.