aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrootjans <grootjans@gmail.com>2011-02-28 12:32:27 +0100
committergrootjans <grootjans@gmail.com>2011-02-28 16:44:06 +0100
commit0fa03d313263991f6f7f55e68097e5e9794e4a7b (patch)
treeebc2118f87a9bf21f9eeaa5fe46d2f5e47a148e5
parente0cfacd3b307b1ec9f0b62b2f953f0a0e85d9d1e (diff)
downloadlombok-0fa03d313263991f6f7f55e68097e5e9794e4a7b.tar.gz
lombok-0fa03d313263991f6f7f55e68097e5e9794e4a7b.tar.bz2
lombok-0fa03d313263991f6f7f55e68097e5e9794e4a7b.zip
Updates examples to use Guice and hibernate validators.
-rw-r--r--usage_examples/onXExample_post.jpage39
-rw-r--r--usage_examples/onXExample_pre.jpage17
2 files changed, 29 insertions, 27 deletions
diff --git a/usage_examples/onXExample_post.jpage b/usage_examples/onXExample_post.jpage
index f71f16a3..85e3c58f 100644
--- a/usage_examples/onXExample_post.jpage
+++ b/usage_examples/onXExample_post.jpage
@@ -1,41 +1,42 @@
+import com.google.inject.Inject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
+import org.hibernate.validator.Min;
public class OnMethodOnParamExample {
- private int fires = 200;
- private int firemen = 20;
- private String fireStationName = "base";
-
- @Deprecated
- public int getFires() {
- return fires;
- }
+ private int bananas;
+ private int radishes;
@Deprecated
- public void setFiremen(int firemen) {
- this.firemen = firemen;
+ public int getBananas() {
+ return bananas;
}
- public void setFireStationName(@SuppressWarnings("all") int fireStationName) {
- this.fireStationName = fireStationName;
+ @Min(10)
+ public int setRadishes(int radishes) {
+ this.radishes = radishes;
}
@Override public String toString() {
- return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires);
+ return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes);
}
}
class OnConstructorExample {
- private final int radishes;
- private int bananas;
+ private final Fireman fireman;
+ private int fires = 10;
- @Deprecated
- public OnConstructorExample(int radishes) {
- this.radishes = radishes;
+ @Inject
+ public OnConstructorExample(Fireman fireman) {
+ this.fireman = fireman;
+ }
+
+ public void setFires(@SuppressWarnings("all") int fires) {
+ this.fires = fires;
}
@Override public String toString() {
- return String.format("I have %d bananas and %d radishes", bananas, radishes);
+ return String.format("Fireman: %s has %d fires", fireman, fires);
}
} \ No newline at end of file
diff --git a/usage_examples/onXExample_pre.jpage b/usage_examples/onXExample_pre.jpage
index 3e91fb3a..1bab3835 100644
--- a/usage_examples/onXExample_pre.jpage
+++ b/usage_examples/onXExample_pre.jpage
@@ -1,23 +1,24 @@
+import com.google.inject.Inject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
+import org.hibernate.validator.Min;
public class OnMethodOnParamExample {
- @Getter(onMethod=@Deprecated) private int fires = 200;
- @Setter(onMethod=@Deprecated) private int firemen = 20;
- @Setter(onParam=@SuppressWarnings("all")) private String fireStationName = "base";
+ @Getter(onMethod=@Deprecated) private int bananas;
+ @Setter(onMethod=@Min(10)) private int radishes;
@Override public String toString() {
- return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires);
+ return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes);
}
}
-@RequiredArgsConstructor(onConstructor=@Deprecated)
+@RequiredArgsConstructor(onConstructor=@Inject)
class OnConstructorExample {
- private final int radishes;
- private int bananas;
+ private final Fireman fireman;
+ @Setter(onParam=@SuppressWarnings("all")) private int fires = 10;
@Override public String toString() {
- return String.format("I have %d bananas and %d radishes", bananas, radishes);
+ return String.format("Fireman: %s has %d fires", fireman, fires);
}
} \ No newline at end of file