improve with examples

This commit is contained in:
Roel Spilker committed 2019-09-12 22:06:02 +02:00
1 parent 80c1b2d2e7
commit 1260297f73
2 files changed
+6 -6

No files matched your search

+5 -5
View File
@@ -1,8 +1,8 @@
import lombok.NonNull;
public class WithExample {
private final int age;
private @NonNull final String name;
private final int age;
public WithExample(String name, int age) {
if (name == null) throw new NullPointerException();
@@ -10,12 +10,12 @@ public class WithExample {
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);
}
public WithExample withAge(int age) {
return this.age == age ? this : new WithExample(name, age);
}
}