aboutsummaryrefslogtreecommitdiff
path: root/website2/usageExamples/experimental
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2016-10-17 23:09:21 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2017-05-29 21:01:53 +0200
commit599b6aab677439ae1bdea2cdca3233d0b763fd3f (patch)
tree8766f124271d056c8e8c22fd1a8a1ada08284275 /website2/usageExamples/experimental
parent4e75ed8f8661033662b2d26c4a42fafa9d61b75f (diff)
downloadlombok-599b6aab677439ae1bdea2cdca3233d0b763fd3f.tar.gz
lombok-599b6aab677439ae1bdea2cdca3233d0b763fd3f.tar.bz2
lombok-599b6aab677439ae1bdea2cdca3233d0b763fd3f.zip
Updated just about all of the pages to the template-based redesign.
Added ajaxified loading for feature pages.
Diffstat (limited to 'website2/usageExamples/experimental')
-rw-r--r--website2/usageExamples/experimental/AccessorsExample_post.jpage20
-rw-r--r--website2/usageExamples/experimental/AccessorsExample_pre.jpage14
-rw-r--r--website2/usageExamples/experimental/DelegateExample_post.jpage97
-rw-r--r--website2/usageExamples/experimental/DelegateExample_pre.jpage37
-rw-r--r--website2/usageExamples/experimental/ExtensionMethodExample_post.jpage21
-rw-r--r--website2/usageExamples/experimental/ExtensionMethodExample_pre.jpage24
-rw-r--r--website2/usageExamples/experimental/FieldDefaultsExample_post.jpage12
-rw-r--r--website2/usageExamples/experimental/FieldDefaultsExample_pre.jpage18
-rw-r--r--website2/usageExamples/experimental/HelperExample_post.jpage14
-rw-r--r--website2/usageExamples/experimental/HelperExample_pre.jpage15
-rw-r--r--website2/usageExamples/experimental/UtilityClassExample_post.jpage11
-rw-r--r--website2/usageExamples/experimental/UtilityClassExample_pre.jpage10
-rw-r--r--website2/usageExamples/experimental/WitherExample_post.jpage21
-rw-r--r--website2/usageExamples/experimental/WitherExample_pre.jpage14
-rw-r--r--website2/usageExamples/experimental/onXExample_post.jpage22
-rw-r--r--website2/usageExamples/experimental/onXExample_pre.jpage15
16 files changed, 365 insertions, 0 deletions
diff --git a/website2/usageExamples/experimental/AccessorsExample_post.jpage b/website2/usageExamples/experimental/AccessorsExample_post.jpage
new file mode 100644
index 00000000..ae5a39db
--- /dev/null
+++ b/website2/usageExamples/experimental/AccessorsExample_post.jpage
@@ -0,0 +1,20 @@
+public class AccessorsExample {
+ private int age = 10;
+
+ public int age() {
+ return this.age;
+ }
+
+ public AccessorsExample age(final int age) {
+ this.age = age;
+ return this;
+ }
+}
+
+class PrefixExample {
+ private String fName = "Hello, World!";
+
+ public String getName() {
+ return this.fName;
+ }
+}
diff --git a/website2/usageExamples/experimental/AccessorsExample_pre.jpage b/website2/usageExamples/experimental/AccessorsExample_pre.jpage
new file mode 100644
index 00000000..f1591aba
--- /dev/null
+++ b/website2/usageExamples/experimental/AccessorsExample_pre.jpage
@@ -0,0 +1,14 @@
+import lombok.experimental.Accessors;
+import lombok.Getter;
+import lombok.Setter;
+
+@Accessors(fluent = true)
+public class AccessorsExample {
+ @Getter @Setter
+ private int age = 10;
+}
+
+class PrefixExample {
+ @Accessors(prefix = "f") @Getter
+ private String fName = "Hello, World!";
+}
diff --git a/website2/usageExamples/experimental/DelegateExample_post.jpage b/website2/usageExamples/experimental/DelegateExample_post.jpage
new file mode 100644
index 00000000..1c5239f1
--- /dev/null
+++ b/website2/usageExamples/experimental/DelegateExample_post.jpage
@@ -0,0 +1,97 @@
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class DelegationExample {
+ private interface SimpleCollection {
+ boolean add(String item);
+ boolean remove(Object item);
+ }
+
+ private final Collection<String> collection = new ArrayList<String>();
+
+ @java.lang.SuppressWarnings("all")
+ public boolean add(final java.lang.String item) {
+ return this.collection.add(item);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean remove(final java.lang.Object item) {
+ return this.collection.remove(item);
+ }
+}
+
+class ExcludesDelegateExample {
+ long counter = 0L;
+
+ private interface Add {
+ boolean add(String x);
+ boolean addAll(Collection<? extends String> x);
+ }
+
+ private final Collection<String> collection = new ArrayList<String>();
+
+ public boolean add(String item) {
+ counter++;
+ return collection.add(item);
+ }
+
+ public boolean addAll(Collection<? extends String> col) {
+ counter += col.size();
+ return collection.addAll(col);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public int size() {
+ return this.collection.size();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean isEmpty() {
+ return this.collection.isEmpty();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean contains(final java.lang.Object arg0) {
+ return this.collection.contains(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public java.util.Iterator<java.lang.String> iterator() {
+ return this.collection.iterator();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public java.lang.Object[] toArray() {
+ return this.collection.toArray();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public <T extends .java.lang.Object>T[] toArray(final T[] arg0) {
+ return this.collection.<T>toArray(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean remove(final java.lang.Object arg0) {
+ return this.collection.remove(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean containsAll(final java.util.Collection<?> arg0) {
+ return this.collection.containsAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean removeAll(final java.util.Collection<?> arg0) {
+ return this.collection.removeAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean retainAll(final java.util.Collection<?> arg0) {
+ return this.collection.retainAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public void clear() {
+ this.collection.clear();
+ }
+}
diff --git a/website2/usageExamples/experimental/DelegateExample_pre.jpage b/website2/usageExamples/experimental/DelegateExample_pre.jpage
new file mode 100644
index 00000000..885ab3a8
--- /dev/null
+++ b/website2/usageExamples/experimental/DelegateExample_pre.jpage
@@ -0,0 +1,37 @@
+import java.util.ArrayList;
+import java.util.Collection;
+
+import lombok.experimental.Delegate;
+
+public class DelegationExample {
+ private interface SimpleCollection {
+ boolean add(String item);
+ boolean remove(Object item);
+ }
+
+ @Delegate(types=SimpleCollection.class)
+ private final Collection<String> collection = new ArrayList<String>();
+}
+
+
+class ExcludesDelegateExample {
+ long counter = 0L;
+
+ private interface Add {
+ boolean add(String x);
+ boolean addAll(Collection<? extends String> x);
+ }
+
+ @Delegate(excludes=Add.class)
+ private final Collection<String> collection = new ArrayList<String>();
+
+ public boolean add(String item) {
+ counter++;
+ return collection.add(item);
+ }
+
+ public boolean addAll(Collection<? extends String> col) {
+ counter += col.size();
+ return collection.addAll(col);
+ }
+}
diff --git a/website2/usageExamples/experimental/ExtensionMethodExample_post.jpage b/website2/usageExamples/experimental/ExtensionMethodExample_post.jpage
new file mode 100644
index 00000000..de46d776
--- /dev/null
+++ b/website2/usageExamples/experimental/ExtensionMethodExample_post.jpage
@@ -0,0 +1,21 @@
+public class ExtensionMethodExample {
+ public String test() {
+ int[] intArray = {5, 3, 8, 2};
+ java.util.Arrays.sort(intArray);
+
+ String iAmNull = null;
+ return Extensions.or(iAmNull, Extensions.toTitleCase("hELlO, WORlD!"));
+ }
+}
+
+class Extensions {
+ public static <T> T or(T obj, T ifNull) {
+ return obj != null ? obj : ifNull;
+ }
+
+ public static String toTitleCase(String in) {
+ if (in.isEmpty()) return in;
+ return "" + Character.toTitleCase(in.charAt(0)) +
+ in.substring(1).toLowerCase();
+ }
+}
diff --git a/website2/usageExamples/experimental/ExtensionMethodExample_pre.jpage b/website2/usageExamples/experimental/ExtensionMethodExample_pre.jpage
new file mode 100644
index 00000000..b3b9f1fa
--- /dev/null
+++ b/website2/usageExamples/experimental/ExtensionMethodExample_pre.jpage
@@ -0,0 +1,24 @@
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod({java.util.Arrays.class, Extensions.class})
+public class ExtensionMethodExample {
+ public String test() {
+ int[] intArray = {5, 3, 8, 2};
+ intArray.sort();
+
+ String iAmNull = null;
+ return iAmNull.or("hELlO, WORlD!".toTitleCase());
+ }
+}
+
+class Extensions {
+ public static <T> T or(T obj, T ifNull) {
+ return obj != null ? obj : ifNull;
+ }
+
+ public static String toTitleCase(String in) {
+ if (in.isEmpty()) return in;
+ return "" + Character.toTitleCase(in.charAt(0)) +
+ in.substring(1).toLowerCase();
+ }
+}
diff --git a/website2/usageExamples/experimental/FieldDefaultsExample_post.jpage b/website2/usageExamples/experimental/FieldDefaultsExample_post.jpage
new file mode 100644
index 00000000..95c17a4b
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/FieldDefaultsExample_pre.jpage b/website2/usageExamples/experimental/FieldDefaultsExample_pre.jpage
new file mode 100644
index 00000000..c8335832
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/HelperExample_post.jpage b/website2/usageExamples/experimental/HelperExample_post.jpage
new file mode 100644
index 00000000..04a97b9f
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/HelperExample_pre.jpage b/website2/usageExamples/experimental/HelperExample_pre.jpage
new file mode 100644
index 00000000..cd86ef3c
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/UtilityClassExample_post.jpage b/website2/usageExamples/experimental/UtilityClassExample_post.jpage
new file mode 100644
index 00000000..70810230
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/UtilityClassExample_pre.jpage b/website2/usageExamples/experimental/UtilityClassExample_pre.jpage
new file mode 100644
index 00000000..85731b81
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/WitherExample_post.jpage b/website2/usageExamples/experimental/WitherExample_post.jpage
new file mode 100644
index 00000000..bb5952af
--- /dev/null
+++ b/website2/usageExamples/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/website2/usageExamples/experimental/WitherExample_pre.jpage b/website2/usageExamples/experimental/WitherExample_pre.jpage
new file mode 100644
index 00000000..5db799fc
--- /dev/null
+++ b/website2/usageExamples/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;
+ }
+}
diff --git a/website2/usageExamples/experimental/onXExample_post.jpage b/website2/usageExamples/experimental/onXExample_post.jpage
new file mode 100644
index 00000000..1be94f2a
--- /dev/null
+++ b/website2/usageExamples/experimental/onXExample_post.jpage
@@ -0,0 +1,22 @@
+import javax.inject.Inject;
+import javax.persistence.Id;
+import javax.persistence.Column;
+import javax.validation.constraints.Max;
+
+public class OnXExample {
+ private long unid;
+
+ @Inject
+ public OnXExample(long unid) {
+ this.unid = unid;
+ }
+
+ @Id @Column(name="unique-id")
+ public long getUnid() {
+ return unid;
+ }
+
+ public void setUnid(@Max(10000) long unid) {
+ this.unid = unid;
+ }
+}
diff --git a/website2/usageExamples/experimental/onXExample_pre.jpage b/website2/usageExamples/experimental/onXExample_pre.jpage
new file mode 100644
index 00000000..f8fcb435
--- /dev/null
+++ b/website2/usageExamples/experimental/onXExample_pre.jpage
@@ -0,0 +1,15 @@
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.inject.Inject;
+import javax.persistence.Id;
+import javax.persistence.Column;
+import javax.validation.constraints.Max;
+
+@AllArgsConstructor(onConstructor=@__(@Inject))
+public class OnXExample {
+ @Getter(onMethod=@__({@Id, @Column(name="unique-id")}))
+ @Setter(onParam=@__(@Max(10000)))
+ private long unid;
+}