blob: a881ed8d5efb40cfd394bc336093dc35e0c87aae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import lombok.NonNull;
public class WithExample {
private final int age;
private @NonNull final String name;
public WithExample(String name, int age) {
if (name == null) throw new NullPointerException();
this.name = name;
this.age = age;
}
public WithExample withAge(int age) {
return this.age == age ? this : new WithExample(name, 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);
}
}
|