I want to use an interface like this :
public interface ResultItem {
public int getConfidence();
public boolean equals(ResultItem item);
public ResultItem cloneWithConfidence(int newConfidence);
}
I have it implemented by different kind of objects representing a voice recognition result.
The idea is, I wish to compare only results of the same kind. That is, if I create a class IntResult
implementing ResultItem
, I want that the method signatures become :
public boolean equals(IntResult item);
public IntResult cloneWithConfidence(int newConfidence);
I feel that there is a design flaw in my interface, because for now I am using pretty ugly casts on the results of cloneWithConfidence and of other methods returning a ResultItem.
Is there a better way?