You cannot override a method this way. AProcessor should be able to accept everything that FileProcessor accepts as input to setHeader . Consider this code:
FileProcessor f = new AProcessor(); String s = f.setHeader("Bah");
This code should work no matter what particular class is used, and not with your AProcessor . Therefore, it makes sense that the test type rejects it.
Something like this will work (since the FileProcessor interface is now parameterized by RT):
public interface FileProccessor<RT> { public RT setHeader(RT header); } public class AProcessor implements FileProccessor<Header> { @Override public Header setHeader(Header header) { return null; } }
Now the class user will need to write:
FileProcessor<Header> f = new AProcessor();
and the setHeader argument must be of type Header ...
source share