Android使用Sugar ORM入门指南

3

我是SugarORM的新手,希望在我的应用程序中使用这个库。在设置完库的元标签之后,我必须为所有类扩展SugarRecord。为此,我创建了一个名为Product的新类如下所示:

@Table
public class ProductTable {
    private String id;
    private String count;

    public ProductTable() {
    }

    public ProductTable(String id, String count) {
        this.id = id;
        this.count = count;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCount() {
        return count;
    }

    public void setCount(String count) {
        this.count = count;
    }
}

为了扩展SugarRecord,我想要一个类,就像这个示例:

public class ProductModel extends SugarRecord<ProductModel> {
    String title;
    String edition;

    public ProductModel(){
    }

    public ProductModel(String title, String edition){
        this.title = title;
        this.edition = edition;
    }
}

但是我遇到了这个错误:
Error:(9, 46) java: type com.orm.SugarRecord does not take parameters

对于这一行代码:

public class ProductModel extends SugarRecord<ProductModel> {

我使用这个文档
1个回答

3

不再需要扩展SugarRecord<ProductModel>,直接使用SugarRecord即可。


谢谢先生,<ProductModel>中的ProductModel是一个类结构吗? - user4790312
那是一个通用参数,因为ProductModel被称为“通用类”。请查看文档以获得更好的理解。 https://docs.oracle.com/javase/tutorial/java/generics/types.html - rafaelc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接