我想要实现从Apache的共享BeanUtils的以下接口:为什么这个@Override不正确?
public interface Converter {
// Convert the specified input object into an output object of the specified type
<T> T convert(java.lang.Class<T> tClass, java.lang.Object o);
}
我实施应采取枚举的子类,String对象转换为指定类型的枚举。我试图使用以下声明:
class EnumConverter implements Converter {
@Override
public Enum convert(Class<Enum> tClass, Object o) {
...
}
}
但编译器不同意我。它输出:
error: EnumConverter is not abstract and does not override abstract method convert(Class,Object) in Converter
error: name clash: convert(Class,Object) in EnumConverter and convert(Class,Object) in Converter have the same erasure, yet neither overrides the other
error: method does not override or implement a method from a supertype
我的实现有什么问题?
UPD。请仔细阅读该问题。我无法更改它在Apache Commons BeanUtils库中的Converter接口。
你需要让你的接口一般为好。 –
@DaveNewton“我想从Apache Commons BeanUtils实现以下接口”。它是我无法更改的第三方库。 –