aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/DelegateExample_pre.jpage
diff options
context:
space:
mode:
Diffstat (limited to 'usage_examples/DelegateExample_pre.jpage')
-rw-r--r--usage_examples/DelegateExample_pre.jpage27
1 files changed, 27 insertions, 0 deletions
diff --git a/usage_examples/DelegateExample_pre.jpage b/usage_examples/DelegateExample_pre.jpage
new file mode 100644
index 00000000..b208c4ca
--- /dev/null
+++ b/usage_examples/DelegateExample_pre.jpage
@@ -0,0 +1,27 @@
+import java.util.ArrayList;
+import java.util.Collection;
+
+import lombok.Delegate;
+
+
+public class DelegateExample {
+ long counter = 0L;
+
+ @Delegate
+ private final Collection<String> collection = new ArrayList<String>();
+
+ public boolean add(String name) {
+ counter++;
+ return collection.add(name);
+ }
+}
+
+class PartialDelegationExample {
+ @Delegate({SimpleCollection.class})
+ private final Collection<String> collection = new ArrayList<String>();
+
+ private interface SimpleCollection {
+ boolean add(String item);
+ boolean remove(Object item);
+ }
+}