The following interface defines two overloaded methods. Both take one parameter where one is of type "java.util.Collection", the other one of "java.util.Set":
public interface MyService {
|
|
void run(Collection<String> values);
|
|
void run(Set<Integer> values);
|
|
}
|
Furthermore a decorator is defined:
@Decorator
|
public interface MyServiceDecorator {
|
|
@Inject @Delegate
|
private MyService delegate;
|
|
void run(Collection<String> values) {
|
delegate.run(values);
|
}
|
|
void run(Set<Integer> values) {
|
delegate.run(values);
|
}
|
|
}
|
A client injects an instance of MyService and invokes "run" using a Set of integer values:
@Inject
|
private MyService myService;
|
|
...
|
Set<Integer> values = new HashSet<>();
|
myService.run(values);
|
...
|
It can be observed that the method " void run(Collection<String> values)" is invoked on the decorator - which is wrong. Changing the order of the method declarations in the interface MyService "solves" the problem.
|