mirror of
https://github.com/tiennm99/lombok.git
synced 2026-05-25 20:01:38 +00:00
22 lines
553 B
Plaintext
22 lines
553 B
Plaintext
import lombok.NonNull;
|
|
|
|
public class WithExample {
|
|
private @NonNull final String name;
|
|
private final int age;
|
|
|
|
public WithExample(String name, int age) {
|
|
if (name == null) throw new NullPointerException();
|
|
this.name = name;
|
|
this.age = age;
|
|
}
|
|
|
|
protected WithExample withName(@NonNull String name) {
|
|
if (name == null) throw new java.lang.NullPointerException("name");
|
|
return this.name == name ? this : new WithExample(name, age);
|
|
}
|
|
|
|
public WithExample withAge(int age) {
|
|
return this.age == age ? this : new WithExample(name, age);
|
|
}
|
|
}
|