mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 02:17:12 +00:00
[With] updated documentation for Wither/With
This commit is contained in:
8 files changed
+90
-101
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.With;
|
||||
|
||||
public class WithExample {
|
||||
@With private final int age;
|
||||
@With(AccessLevel.PROTECTED) @NonNull private final String name;
|
||||
|
||||
public WithExample(String name, int age) {
|
||||
if (name == null) throw new NullPointerException();
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
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(name, age);
|
||||
}
|
||||
|
||||
protected WitherExample withName(@NonNull String name) {
|
||||
if (name == null) throw new java.lang.NullPointerException("name");
|
||||
return this.name == name ? this : new WitherExample(name, age);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
public class WitherExample {
|
||||
@Wither private final int age;
|
||||
@Wither(AccessLevel.PROTECTED) @NonNull private final String name;
|
||||
|
||||
public WitherExample(String name, int age) {
|
||||
if (name == null) throw new NullPointerException();
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user