aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/experimental
diff options
context:
space:
mode:
Diffstat (limited to 'usage_examples/experimental')
-rw-r--r--usage_examples/experimental/FieldDefaultsExample_post.jpage12
-rw-r--r--usage_examples/experimental/FieldDefaultsExample_pre.jpage18
-rw-r--r--usage_examples/experimental/ValueExample_post.jpage140
-rw-r--r--usage_examples/experimental/ValueExample_pre.jpage19
-rw-r--r--usage_examples/experimental/WitherExample_post.jpage21
-rw-r--r--usage_examples/experimental/WitherExample_pre.jpage14
6 files changed, 224 insertions, 0 deletions
diff --git a/usage_examples/experimental/FieldDefaultsExample_post.jpage b/usage_examples/experimental/FieldDefaultsExample_post.jpage
new file mode 100644
index 00000000..95c17a4b
--- /dev/null
+++ b/usage_examples/experimental/FieldDefaultsExample_post.jpage
@@ -0,0 +1,12 @@
+public class FieldDefaultsExample {
+ public final int a;
+ private final int b;
+ private int c;
+ final int d;
+
+ FieldDefaultsExample() {
+ a = 0;
+ b = 0;
+ d = 0;
+ }
+}
diff --git a/usage_examples/experimental/FieldDefaultsExample_pre.jpage b/usage_examples/experimental/FieldDefaultsExample_pre.jpage
new file mode 100644
index 00000000..a0a38f7a
--- /dev/null
+++ b/usage_examples/experimental/FieldDefaultsExample_pre.jpage
@@ -0,0 +1,18 @@
+import lombok.AccessLevel;
+import lombok.experimental.FieldDefaults;
+import lombok.experimental.NonFinal;
+import lombok.experimental.PackagePrivate;
+
+@FieldDefaults(makeFinal = true, level=AccessLevel.PRIVATE)
+public class FieldDefaultsExample {
+ public final int a;
+ int b;
+ @NonFinal int c;
+ @PackagePrivate int d;
+
+ FieldDefaultsExample() {
+ a = 0;
+ b = 0;
+ d = 0;
+ }
+}
diff --git a/usage_examples/experimental/ValueExample_post.jpage b/usage_examples/experimental/ValueExample_post.jpage
new file mode 100644
index 00000000..47de72a5
--- /dev/null
+++ b/usage_examples/experimental/ValueExample_post.jpage
@@ -0,0 +1,140 @@
+import java.util.Arrays;
+
+public final class ValueExample {
+ private final String name;
+ private int age;
+ private final double score;
+ protected final String[] tags;
+
+ @java.beans.ConstructorProperties({"name", "age", "score", "tags"})
+ public ValueExample(String name, int age, double score, String[] tags) {
+ this.name = name;
+ this.age = age;
+ this.score = score;
+ this.tags = tags;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public int getAge() {
+ return this.age;
+ }
+
+ public double getScore() {
+ return this.score;
+ }
+
+ public String[] getTags() {
+ return this.tags;
+ }
+
+ public ValueExample withName(String name) {
+ return this.name == name ? this : new ValueExample(name, age, score, tags);
+ }
+
+ public ValueExample withScore(double score) {
+ return this.score == score ? this : new ValueExample(name, age, score, tags);
+ }
+
+ public ValueExample withTags(String[] tags) {
+ return this.tags == tags ? this : new ValueExample(name, age, score, tags);
+ }
+
+ @java.lang.Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof ValueExample)) return false;
+ final ValueExample other = (ValueExample)o;
+ final Object this$name = this.getName();
+ final Object other$name = other.getName();
+ if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
+ if (this.getAge() != other.getAge()) return false;
+ if (Double.compare(this.getScore(), other.getScore()) != 0) return false;
+ if (!Arrays.deepEquals(this.getTags(), other.getTags())) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ final Object $name = this.getName();
+ result = result * PRIME + ($name == null ? 0 : $name.hashCode());
+ result = result * PRIME + this.getAge();
+ final long $score = Double.doubleToLongBits(this.getScore());
+ result = result * PRIME + (int)($score >>> 32 ^ $score);
+ result = result * PRIME + Arrays.deepHashCode(this.getTags());
+ return result;
+ }
+
+ @java.lang.Override
+ public String toString() {
+ return "ValueExample(name=" + getName() + ", age=" + getAge() + ", score=" + getScore() + ", tags=" + Arrays.deepToString(getTags()) + ")";
+ }
+
+ ValueExample withAge(int age) {
+ return this.age == age ? this : new ValueExample(name, age, score, tags);
+ }
+
+ public static final class Exercise<T> {
+ private final String name;
+ private final T value;
+
+ private Exercise(String name, T value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public static <T> Exercise<T> of(String name, T value) {
+ return new Exercise<T>(name, value);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public T getValue() {
+ return this.value;
+ }
+
+ public Exercise<T> withName(String name) {
+ return this.name == name ? this : new Exercise<T>(name, value);
+ }
+
+ public Exercise<T> withValue(T value) {
+ return this.value == value ? this : new Exercise<T>(name, value);
+ }
+
+ @java.lang.Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof ValueExample.Exercise)) return false;
+ final Exercise<?> other = (Exercise<?>)o;
+ final Object this$name = this.getName();
+ final Object other$name = other.getName();
+ if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
+ final Object this$value = this.getValue();
+ final Object other$value = other.getValue();
+ if (this$value == null ? other$value != null : !this$value.equals(other$value)) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ final Object $name = this.getName();
+ result = result * PRIME + ($name == null ? 0 : $name.hashCode());
+ final Object $value = this.getValue();
+ result = result * PRIME + ($value == null ? 0 : $value.hashCode());
+ return result;
+ }
+
+ @java.lang.Override
+ public String toString() {
+ return "ValueExample.Exercise(name=" + getName() + ", value=" + getValue() + ")";
+ }
+ }
+} \ No newline at end of file
diff --git a/usage_examples/experimental/ValueExample_pre.jpage b/usage_examples/experimental/ValueExample_pre.jpage
new file mode 100644
index 00000000..d9550c25
--- /dev/null
+++ b/usage_examples/experimental/ValueExample_pre.jpage
@@ -0,0 +1,19 @@
+import lombok.AccessLevel;
+import lombok.experimental.NonFinal;
+import lombok.experimental.Value;
+import lombok.experimental.Wither;
+import lombok.ToString;
+
+@Value public class ValueExample {
+ String name;
+ @Wither(AccessLevel.PACKAGE) @NonFinal int age;
+ double score;
+ protected String[] tags;
+
+ @ToString(includeFieldNames=true)
+ @Value(staticConstructor="of")
+ public static class Exercise<T> {
+ String name;
+ T value;
+ }
+}
diff --git a/usage_examples/experimental/WitherExample_post.jpage b/usage_examples/experimental/WitherExample_post.jpage
new file mode 100644
index 00000000..bb5952af
--- /dev/null
+++ b/usage_examples/experimental/WitherExample_post.jpage
@@ -0,0 +1,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);
+ }
+} \ No newline at end of file
diff --git a/usage_examples/experimental/WitherExample_pre.jpage b/usage_examples/experimental/WitherExample_pre.jpage
new file mode 100644
index 00000000..5db799fc
--- /dev/null
+++ b/usage_examples/experimental/WitherExample_pre.jpage
@@ -0,0 +1,14 @@
+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;
+ }
+}