mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 18:18:48 +00:00
improve with examples
This commit is contained in:
1 parent
80c1b2d2e7
commit
1260297f73
2 files changed
+6
-6
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user