public class UserHeaderRepository<TEntity>{
private final CollectionReference collectionReference;
private final Class<TEntity> entityClass;
public static UserHeaderRepository getInstance()
{
return new UserHeaderRepository(UserHeader.class);
}
public UserHeaderRepository ( Class < TEntity > entityClass ) {
this.entityClass = entityClass;
FirebaseFirestore db = FirebaseFirestore.getInstance();
this.collectionReference = db.collection("global_community");
}
我不知道为什么会出现以下错误:
unchecked call to UserHeaderRepository(Class<TEntity>) row type 'as a member of raw type '../appRepository/UserHeaderRepository'
最佳答案
您是using raw types where you were supposed to use the parameterized type,将getInstance
方法更改为此,
public static UserHeaderRepository<UserHeader> getInstance() {
return new UserHeaderRepository<>(UserHeader.class);
}
同样,它也不应该是错误,应该从编译器发出警告。