我正在尝试实现一个可以访问两个或多个可能的类对象的构造函数。(PS。这是一个内部类,对于那些质疑静态类的人)
...
public static class Builder {
protected String mTitle;
protected List<ReviewItem> mPages = new ArrayList<ReviewItem>();
protected boolean mRequired = false;
protected String mParentKey;
private final ModelCallbacks mModelCallbacks;
private final Class<Fragment> mFragmentClass;
public Builder(String title, ModelCallbacks callbacks, Class<PageFragment> clazz) {
mTitle = title;
mModelCallbacks = callbacks;
mFragmentClass = clazz;
}
public Builder(String title, ModelCallbacks callbacks, Class<ListPageFragment> clazz) {
mTitle = title;
mModelCallbacks = callbacks;
mFragmentClass = clazz;
}
}
...
ListPageFragment 继承
java.lang.Object
↳ android.app.Fragment
↳ android.app.ListFragment
↳ my.app.ListPageFragment
PageFragment 继承
java.lang.Object
↳ android.app.Fragment
↳ my.app.PageFragment
错误:
Method Builder(String, ModelCallbacks, Class) 与 Page.Builder 类型中的另一个方法具有相同的擦除 Builder(String, ModelCallbacks, Class)
当前的错误是有道理的,但我怎样才能实现或确保它clazz
是 PageFragment 或 ListPageFragment 类型?