diff options
Diffstat (limited to 'website/usageExamples/WithExample_post.jpage')
-rw-r--r-- | website/usageExamples/WithExample_post.jpage | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/website/usageExamples/WithExample_post.jpage b/website/usageExamples/WithExample_post.jpage new file mode 100644 index 00000000..a881ed8d --- /dev/null +++ b/website/usageExamples/WithExample_post.jpage @@ -0,0 +1,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); + } +} |