aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/DelegateExample_pre.jpage
blob: b208c4cacef6d646c78a3eaab8150b00f299337f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
	}
}