I am trying to encapsulate 3 interfaces in one (ICountable) and make concrete class implement this encapsulating interface. `ICountable code:
public interface ICountable extends IAddable, Cloneable, Serializable {}
Addable interface definition is:
public interface IAddable<T> {
T add(T other);
}
now when I am trying to implement ICountable in the concrete class (BaseCounter) I am getting the error that not all methods are implemented (complaining on add method). I fail to understand why. The BaseCounter code is as follows:
public class BaseCounter implements ICountable {
@Override
public BaseCounter add(BaseCounter other) {
// TODO Auto-generated method stub
return null;
}
}
Change add method signature to
public ICountable add(ICountable other)
fixes the situation.
However, what I wanted originally, was to make one interface (ICountable) that extends 3 others (2 markers and 1 interface that describes the ability of the implementing class to perform add on the object of the same type). What I need to change in order to make add method implementation in BaseCounter look like this:
public BaseCounter add(BaseCounter other)
I would appreciate your suggestions.
1 Add generic to ICountable
2 Specify generic in implementation