diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-05-09 22:05:43 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-05-09 22:05:43 +0200 |
commit | 045bc9a60d7d97985791ec80b8b423a49e5c1a7a (patch) | |
tree | a3682f3575236b716374d5e02614d5cdeaf13d73 /usage_examples | |
parent | 66f8ec612f917f90c019b357c93f82397791cc53 (diff) | |
download | lombok-045bc9a60d7d97985791ec80b8b423a49e5c1a7a.tar.gz lombok-045bc9a60d7d97985791ec80b8b423a49e5c1a7a.tar.bz2 lombok-045bc9a60d7d97985791ec80b8b423a49e5c1a7a.zip |
Updated Delegate docs now that we've changed how it works (it no longer detects that you've implemented a few to-be delegated methods yourself).
Diffstat (limited to 'usage_examples')
-rw-r--r-- | usage_examples/DelegateExample_post.jpage | 66 | ||||
-rw-r--r-- | usage_examples/DelegateExample_pre.jpage | 34 |
2 files changed, 56 insertions, 44 deletions
diff --git a/usage_examples/DelegateExample_post.jpage b/usage_examples/DelegateExample_post.jpage index 28c1bbb7..af2acc1a 100644 --- a/usage_examples/DelegateExample_post.jpage +++ b/usage_examples/DelegateExample_post.jpage @@ -2,15 +2,45 @@ import java.util.ArrayList; import java.util.Collection; import lombok.Delegate; -public class DelegateExample { +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>(); + + @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; - @Delegate + + 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 name) { + public boolean add(String item) { counter++; - return collection.add(name); + return collection.add(item); + } + + public boolean addAll(Collection<? extends String> col) { + counter += col.size(); + return collection.addAll(col); } @java.lang.SuppressWarnings("all") @@ -54,11 +84,6 @@ public class DelegateExample { } @java.lang.SuppressWarnings("all") - public boolean addAll(final java.util.Collection<? extends java.lang.String> arg0) { - return this.collection.addAll(arg0); - } - - @java.lang.SuppressWarnings("all") public boolean removeAll(final java.util.Collection<?> arg0) { return this.collection.removeAll(arg0); } @@ -73,26 +98,3 @@ public class DelegateExample { this.collection.clear(); } } - -class PartialDelegationExample { - - @Delegate({SimpleCollection.class}) - private final Collection<String> collection = new ArrayList<String>(); - - private interface SimpleCollection { - - boolean add(String item); - - boolean remove(Object item); - } - - @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); - } -}
\ No newline at end of file diff --git a/usage_examples/DelegateExample_pre.jpage b/usage_examples/DelegateExample_pre.jpage index b208c4ca..b6f05dfb 100644 --- a/usage_examples/DelegateExample_pre.jpage +++ b/usage_examples/DelegateExample_pre.jpage @@ -3,25 +3,35 @@ import java.util.Collection; import lombok.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>(); +} + -public class DelegateExample { +class ExcludesDelegateExample { long counter = 0L; - @Delegate + 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 name) { + public boolean add(String item) { counter++; - return collection.add(name); + return collection.add(item); } -} - -class PartialDelegationExample { - @Delegate({SimpleCollection.class}) - private final Collection<String> collection = new ArrayList<String>(); - private interface SimpleCollection { - boolean add(String item); - boolean remove(Object item); + public boolean addAll(Collection<? extends String> col) { + counter += col.size(); + return collection.addAll(col); } } |