diff options
Diffstat (limited to 'usage_examples/experimental')
10 files changed, 101 insertions, 54 deletions
diff --git a/usage_examples/experimental/BuilderExample_post.jpage b/usage_examples/experimental/BuilderExample_post.jpage deleted file mode 100644 index 624b236b..00000000 --- a/usage_examples/experimental/BuilderExample_post.jpage +++ /dev/null @@ -1,40 +0,0 @@ -public class BuilderExample { - private String name; - private int age; - - BuilderExample(String name, int age) { - this.name = name; - this.age = age; - } - - public static BuilderExampleBuilder builder() { - return new BuilderExampleBuilder(); - } - - public static class BuilderExampleBuilder { - private String name; - private int age; - - BuilderExampleBuilder() { - } - - public BuilderExampleBuilder name(String name) { - this.name = name; - return this; - } - - public BuilderExampleBuilder age(int age) { - this.age = age; - return this; - } - - public BuilderExample build() { - return new BuilderExample(name, age); - } - - @java.lang.Override - public String toString() { - return "BuilderExample.BuilderExampleBuilder(name = " + this.name + ", age = " + this.age + ")"; - } - } -}
\ No newline at end of file diff --git a/usage_examples/experimental/BuilderExample_pre.jpage b/usage_examples/experimental/BuilderExample_pre.jpage deleted file mode 100644 index 9c754352..00000000 --- a/usage_examples/experimental/BuilderExample_pre.jpage +++ /dev/null @@ -1,7 +0,0 @@ -import lombok.experimental.Builder; - -@Builder -public class BuilderExample { - private String name; - private int age; -} diff --git a/usage_examples/experimental/HelperExample_post.jpage b/usage_examples/experimental/HelperExample_post.jpage new file mode 100644 index 00000000..04a97b9f --- /dev/null +++ b/usage_examples/experimental/HelperExample_post.jpage @@ -0,0 +1,14 @@ +public class HelperExample { + int someMethod(int arg1) { + int localVar = 5; + + class Helpers { + int helperMethod(int arg) { + return arg + localVar; + } + } + Helpers $Helpers = new Helpers(); + + return $Helpers.helperMethod(10); + } +} diff --git a/usage_examples/experimental/HelperExample_pre.jpage b/usage_examples/experimental/HelperExample_pre.jpage new file mode 100644 index 00000000..cd86ef3c --- /dev/null +++ b/usage_examples/experimental/HelperExample_pre.jpage @@ -0,0 +1,15 @@ +import lombok.experimental.Helper; + +public class HelperExample { + int someMethod(int arg1) { + int localVar = 5; + + @Helper class Helpers { + int helperMethod(int arg) { + return arg + localVar; + } + } + + return helperMethod(10); + } +} diff --git a/usage_examples/experimental/UtilityClassExample_post.jpage b/usage_examples/experimental/UtilityClassExample_post.jpage new file mode 100644 index 00000000..70810230 --- /dev/null +++ b/usage_examples/experimental/UtilityClassExample_post.jpage @@ -0,0 +1,11 @@ +public final class UtilityClassExample { + private static final int CONSTANT = 5; + + private UtilityClassExample() { + throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } + + public static void addSomething(int in) { + return in + CONSTANT; + } +} diff --git a/usage_examples/experimental/UtilityClassExample_pre.jpage b/usage_examples/experimental/UtilityClassExample_pre.jpage new file mode 100644 index 00000000..85731b81 --- /dev/null +++ b/usage_examples/experimental/UtilityClassExample_pre.jpage @@ -0,0 +1,10 @@ +import lombok.experimental.UtilityClass; + +@UtilityClass +public class UtilityClassExample { + private final int CONSTANT = 5; + + public void addSomething(int in) { + return in + CONSTANT; + } +} diff --git a/usage_examples/experimental/WitherExample_post.jpage b/usage_examples/experimental/WitherExample_post.jpage index bb5952af..3447192a 100644 --- a/usage_examples/experimental/WitherExample_post.jpage +++ b/usage_examples/experimental/WitherExample_post.jpage @@ -3,19 +3,19 @@ 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); + 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(age, name); + return this.name == name ? this : new WitherExample(name, age); } }
\ No newline at end of file diff --git a/usage_examples/experimental/onXExample_pre.jpage b/usage_examples/experimental/onXExample_pre.jpage index f8fcb435..e54371ae 100644 --- a/usage_examples/experimental/onXExample_pre.jpage +++ b/usage_examples/experimental/onXExample_pre.jpage @@ -9,7 +9,9 @@ import javax.validation.constraints.Max; @AllArgsConstructor(onConstructor=@__(@Inject)) public class OnXExample { - @Getter(onMethod=@__({@Id, @Column(name="unique-id")})) - @Setter(onParam=@__(@Max(10000))) +// @Getter(onMethod=@__({@Id, @Column(name="unique-id")})) //JDK7 +// @Setter(onParam=@__(@Max(10000))) //JDK7 + @Getter(onMethod_={@Id, @Column(name="unique-id")}) //JDK8 + @Setter(onParam_=@Max(10000)) //JDK8 private long unid; } diff --git a/usage_examples/experimental/varExample_post.jpage b/usage_examples/experimental/varExample_post.jpage new file mode 100644 index 00000000..d0a7c124 --- /dev/null +++ b/usage_examples/experimental/varExample_post.jpage @@ -0,0 +1,21 @@ +import java.util.ArrayList; +import lombok.var; + +public class VarExample { + public String example() { + ArrayList<String> example = new ArrayList<String>(); + example.add("Hello, World!"); + final String foo = example.get(0); + return foo.toLowerCase(); + } + + public void example2() { + ArrayList<String> list = new ArrayList<String>(); + list.add("zero"); + list.add("one"); + list.add("two"); + for(int i = 0; i < list.size(); ++i) { + System.out.printf("%d: %s\n", i, list.get(i)); + } + } +} diff --git a/usage_examples/experimental/varExample_pre.jpage b/usage_examples/experimental/varExample_pre.jpage new file mode 100644 index 00000000..e58c4c0d --- /dev/null +++ b/usage_examples/experimental/varExample_pre.jpage @@ -0,0 +1,21 @@ +import java.util.ArrayList; +import lombok.var; + +public class VarExample { + public String example() { + var example = new ArrayList<String>(); + example.add("Hello, World!"); + final var foo = example.get(0); + return foo.toLowerCase(); + } + + public void example2() { + var list = new ArrayList<String>(); + list.add("zero"); + list.add("one"); + list.add("two"); + for(var i = 0; i < list.size(); ++i) { + System.out.printf("%d: %s\n", i, list.get(i)); + } + } +} |