mirror of
https://github.com/tiennm99/lombok.git
synced 2026-05-27 14:22:19 +00:00
28 lines
553 B
Plaintext
28 lines
553 B
Plaintext
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);
|
|
}
|
|
}
|