aboutsummaryrefslogtreecommitdiff
path: root/usage_examples
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-07-22 23:23:46 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-07-22 23:23:46 +0200
commit45697b50816df79475a8bb69dc89ff68747fbfe6 (patch)
tree25cb023eec1f74baf5063cc5a58a5351ee43d6f0 /usage_examples
parent4c03e3d220900431085897878d4888bf530b31ec (diff)
parentdeed98be16e5099af52d951fc611f86a82a42858 (diff)
downloadlombok-45697b50816df79475a8bb69dc89ff68747fbfe6.tar.gz
lombok-45697b50816df79475a8bb69dc89ff68747fbfe6.tar.bz2
lombok-45697b50816df79475a8bb69dc89ff68747fbfe6.zip
Merge branch 'master' into jdk8. Also added some major fixes whilst merging.
Conflicts: src/core/lombok/javac/handlers/JavacHandlerUtil.java src/utils/lombok/javac/CommentCatcher.java src/utils/lombok/javac/Javac.java
Diffstat (limited to 'usage_examples')
-rw-r--r--usage_examples/GetterLazyExample_post.jpage19
-rw-r--r--usage_examples/GetterSetterExample_post.jpage22
-rw-r--r--usage_examples/GetterSetterExample_pre.jpage14
-rw-r--r--usage_examples/NonNullExample_post.jpage13
-rw-r--r--usage_examples/NonNullExample_pre.jpage10
-rw-r--r--usage_examples/ValueExample_post.jpage (renamed from usage_examples/experimental/ValueExample_post.jpage)0
-rw-r--r--usage_examples/ValueExample_pre.jpage (renamed from usage_examples/experimental/ValueExample_pre.jpage)0
-rw-r--r--usage_examples/experimental/BuilderExample_post.jpage40
-rw-r--r--usage_examples/experimental/BuilderExample_pre.jpage7
9 files changed, 116 insertions, 9 deletions
diff --git a/usage_examples/GetterLazyExample_post.jpage b/usage_examples/GetterLazyExample_post.jpage
index 9f4b1ba3..afed1748 100644
--- a/usage_examples/GetterLazyExample_post.jpage
+++ b/usage_examples/GetterLazyExample_post.jpage
@@ -1,18 +1,19 @@
public class GetterLazyExample {
- private double[] $lombok$lazy1v;
- private volatile boolean $lombok$lazy1i;
- private final Object $lombok$lazyLock = new Object[0];
+ private final java.util.concurrent.AtomicReference<java.lang.Object> cached = new java.util.concurrent.AtomicReference<java.lang.Object>();
public double[] getCached() {
- if (!this.$lombok$lazy1i) {
- synchronized (this.$lombok$lazyLock) {
- if (!this.$lombok$lazy1i) {
- this.$lombok$lazy1v = expensive();
- this.$lombok$lazy1i = true;
+ java.lang.Object value = this.cached.get();
+ if (value == null) {
+ synchronized(value) {
+ value = this.cached.get();
+ if (value == null) {
+ final double[] actualValue = expensive();
+ value = actualValue == null ? this.cached : actualValue;
+ this.cached.set(value);
}
}
}
- return this.$lombok$lazy1v;
+ return (double[])(value == this.cached ? null : value);
}
private double[] expensive() {
diff --git a/usage_examples/GetterSetterExample_post.jpage b/usage_examples/GetterSetterExample_post.jpage
index b99ba7e1..241a3a4e 100644
--- a/usage_examples/GetterSetterExample_post.jpage
+++ b/usage_examples/GetterSetterExample_post.jpage
@@ -1,19 +1,41 @@
public class GetterSetterExample {
+ /**
+ * Age of the person. Water is wet.
+ */
private int age = 10;
+
+ /**
+ * Name of the person.
+ */
private String name;
@Override public String toString() {
return String.format("%s (age: %d)", name, age);
}
+ /**
+ * Age of the person. Water is wet.
+ *
+ * @return The current value of this person's age. Circles are round.
+ */
public int getAge() {
return age;
}
+ /**
+ * Age of the person. Water is wet.
+ *
+ * @param age New value for this person's age. Sky is blue.
+ */
public void setAge(int age) {
this.age = age;
}
+ /**
+ * Changes the name of this person.
+ *
+ * @param name The new value.
+ */
protected void setName(String name) {
this.name = name;
}
diff --git a/usage_examples/GetterSetterExample_pre.jpage b/usage_examples/GetterSetterExample_pre.jpage
index 9ef0532c..4183aa5d 100644
--- a/usage_examples/GetterSetterExample_pre.jpage
+++ b/usage_examples/GetterSetterExample_pre.jpage
@@ -3,7 +3,21 @@ import lombok.Getter;
import lombok.Setter;
public class GetterSetterExample {
+ /**
+ * Age of the person. Water is wet.
+ *
+ * @param age New value for this person's age. Sky is blue.
+ * @return The current value of this person's age. Circles are round.
+ */
@Getter @Setter private int age = 10;
+
+ /**
+ * Name of the person.
+ * -- SETTER --
+ * Changes the name of this person.
+ *
+ * @param name The new value.
+ */
@Setter(AccessLevel.PROTECTED) private String name;
@Override public String toString() {
diff --git a/usage_examples/NonNullExample_post.jpage b/usage_examples/NonNullExample_post.jpage
new file mode 100644
index 00000000..24175e06
--- /dev/null
+++ b/usage_examples/NonNullExample_post.jpage
@@ -0,0 +1,13 @@
+import lombok.NonNull;
+
+public class NonNullExample extends Something {
+ private String name;
+
+ public NonNullExample(@NonNull Person person) {
+ super("Hello");
+ if (person == null) {
+ throw new NullPointerException("person");
+ }
+ this.name = person.getName();
+ }
+}
diff --git a/usage_examples/NonNullExample_pre.jpage b/usage_examples/NonNullExample_pre.jpage
new file mode 100644
index 00000000..47556ce7
--- /dev/null
+++ b/usage_examples/NonNullExample_pre.jpage
@@ -0,0 +1,10 @@
+import lombok.NonNull;
+
+public class NonNullExample extends Something {
+ private String name;
+
+ public NonNullExample(@NonNull Person person) {
+ super("Hello");
+ this.name = person.getName();
+ }
+}
diff --git a/usage_examples/experimental/ValueExample_post.jpage b/usage_examples/ValueExample_post.jpage
index ac9b64d1..ac9b64d1 100644
--- a/usage_examples/experimental/ValueExample_post.jpage
+++ b/usage_examples/ValueExample_post.jpage
diff --git a/usage_examples/experimental/ValueExample_pre.jpage b/usage_examples/ValueExample_pre.jpage
index d9550c25..d9550c25 100644
--- a/usage_examples/experimental/ValueExample_pre.jpage
+++ b/usage_examples/ValueExample_pre.jpage
diff --git a/usage_examples/experimental/BuilderExample_post.jpage b/usage_examples/experimental/BuilderExample_post.jpage
new file mode 100644
index 00000000..624b236b
--- /dev/null
+++ b/usage_examples/experimental/BuilderExample_post.jpage
@@ -0,0 +1,40 @@
+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
new file mode 100644
index 00000000..9c754352
--- /dev/null
+++ b/usage_examples/experimental/BuilderExample_pre.jpage
@@ -0,0 +1,7 @@
+import lombok.experimental.Builder;
+
+@Builder
+public class BuilderExample {
+ private String name;
+ private int age;
+}