aboutsummaryrefslogtreecommitdiff
path: root/website/usageExamples/experimental/WitherExample_post.jpage
blob: bb5952af1615d300b3f4ad5d01e0ce5a7f7d9828 (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 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(age, name);
	}
	
	protected WitherExample withName(@NonNull String name) {
		if (name == null) throw new java.lang.NullPointerException("name");
		return this.name == name ? this : new WitherExample(age, name);
	}
}