Answer the question
In order to leave comments, you need to log in
How to make the right generics?
There are 2 interfaces:
First:
public interface ArgsConverter<D> {
public void prepare(...);
public D conv(...., Object[] args );
}
public interface Callback<D> {
MethType getMethodType();
Class<D> getDataObjectClass();
ArgsConverter<D> conv();
Object execute(D data);
}
<Callback<? extends Object>>
Callback<? extends Object> cb = CALLBACKS.stream....;
// convert ARRAY of arguments to DATA OBJECT
return cb.execute(cb.conv().conv( args));
The method execute(capture#4-of ? extends Object) in the type Callback<capture#4-of ? extends Object> is not applicable for the arguments (capture#5-of ? extends Object)
@SuppressWarnings("rawtypes")
Answer the question
In order to leave comments, you need to log in
Why are you making client code do all the work for you?
Why is ArgsConverter conv() sticking out? at the callback?
Try rewriting your execute to this:
public Object execute(Object[] args) {
ArgsConverter<?> convImpl = conv();
return convImpl.conv(args);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question