mirror of
https://github.com/tiennm99/lombok.git
synced 2026-05-26 17:55:36 +00:00
21 lines
564 B
Plaintext
21 lines
564 B
Plaintext
import lombok.NonNull;
|
|
|
|
public class WitherExample {
|
|
private final int age;
|
|
private @NonNull final String name;
|
|
|
|
public WitherExample(String name, int age) {
|
|
if (name == null) throw new NullPointerException();
|
|
this.name = name;
|
|
this.age = age;
|
|
}
|
|
|
|
public WitherExample withAge(int age) {
|
|
return this.age == age ? this : new WitherExample(name, age);
|
|
}
|
|
|
|
protected WitherExample withName(@NonNull String name) {
|
|
if (name == null) throw new java.lang.NullPointerException("name");
|
|
return this.name == name ? this : new WitherExample(name, age);
|
|
}
|
|
} |