Below is an example of what I'm trying to accomplish. I'm trying to create LibraryRunner which implements GenericRunner. However I'm getting an IDE warning that LibraryRunner does not implement the methods in the GenericRunner interface. Which makes sense, the method signature doesn't match, but how can I make the method signature match while still using the LibraryCalculator which extends the GenericCalculator?
public class LibraryRunner implements GenericRunner {
@Override
public <T> T run(LibraryCalculator<T> calculator) {
return T;
}
}
public interface GenericRunner {
<T, A> T run(GenericCalculator<T, A> calculator);
}
public interface LibraryCalculator<T> extends GenericCalculator<T, LibraryAlgorithm> {
T calc(LibraryAlgorithm algorithm) throws LibraryException;
}
public interface GenericCalculator<T, A> {
T calc(A algorithm) throws Exception;
}
public class LibraryException extends Exception {
}