我如何重构这个例子来避免这种我需要在每种数据类型中检查 isInstance 的情况?有什么我可以遵循的模式吗?
public interface GenericData {}
public interface IntegerData extends GenericData{
public Integer Data();
}
public interface StringData extends GenericData{
public String Data();
}
public interface Client {
public boolean LoadData(GenericData data);
}
public class IntegerClientImpl implements Client{
public boolean LoadData(GenericData data){
return IntegerData.class.isInstance(data);
};
}