diff options
Diffstat (limited to 'usage_examples/DelegateExample_pre.jpage')
-rw-r--r-- | usage_examples/DelegateExample_pre.jpage | 34 |
1 files changed, 22 insertions, 12 deletions
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); } } |