构造函数,使用自定义对象的Arraylists进行初始化

时间:2016-04-04 14:29:18

标签: android arraylist constructor initialization

我正在使用ActiveAndroid库(数据库)进行开发。图书馆需要POJOS作为自定义对象,所以我已经制作了一些,但我反对一个问题。其中一个POJOS有2个arraylist,其中一个带有自定义对象,我在初始化对象方面遇到了问题。

@Table(name = "INVOICE", id = "_id")
public class modelInvoice extends Model {

    // This is the unique id given by the server
    @Column(name = "invoice_id", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
    public String invoice_id;

    @Column(name = "supplier_id")
    public long supplier_id;

    @Column(name = "send_date")
    public long send_date;

    @Column(name = "license")
    public String license;

    @Column(name = "container_id")
    public List<Long> container_id;

    @Column(name = "kg_aprox")
    public double kg_aprox;

    @Column(name = "vol_total")
    public double vol_total;

    @Column(name = "presents")
    public List<modelPresent> presents;

    @Column(name = "observations")
    public String observations;

    /***
     * CONSTRUCTOR
     */

    public modelInvoice() {
        super();
    }

    public modelInvoice(String invoice_id, long supplier_id, long send_date, String license, List<Long> container_id, double kg_aprox, double vol_total, List<modelPresent> presents, String observations) {
        this.invoice_id = invoice_id;
        this.supplier_id = supplier_id;
        this.send_date = send_date;
        this.license = license;
        this.container_id = container_id;
        this.kg_aprox = kg_aprox;
        this.vol_total = vol_total;
        this.presents = presents;
        this.observations = observations;
    }

    public modelInvoice(modelInvoice ma) {
        this.invoice_id = ma.invoice_id;
        this.supplier_id = ma.supplier_id;
        this.send_date = ma.send_date;
        this.license = ma.license;
        this.contenedores_id = ma.contenedores_id;
        this.kg_aprox = ma.kg_aprox;
        this.vol_total = ma.vol_total;
        this.presents = ma.presents;
        this.observations = ma.observations;
    }

ModelPresent添加:

@Table(name = "PRESENT", id = "_id")
public class modelPresent extends Model {

    // This is the unique id given by the server
    @Column(name = "present_id", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
    public long present_id;

    @Column(name = "supplier_id")
    public long supplier_id;

    @Column(name = "status_id")
    public long status_id;

    @Column(name = "type_id")
    public long type_id;

    @Column(name = "amount")
    public String amount;

    @Column(name = "description")
    public String description;

    /***
     * CONSTRUCTOR
     */

    public modelPresent() {
        super();
    }

    public modelPresent(long present_id, long supplier_id, long status_id, long type_id, String amount, String description) {
        super();
        this.present_id = present_id;
        this.supplier_id = supplier_id;
        this.status_id = status_id;
        this.type_id = type_id;
        this.amount = amount;
        this.description = description;
    }

    public modelPresent(modelGratificacion mg) {
        super();
        this.present_id = mg.present_id;
        this.supplier_id = mg.supplier_id;
        this.status_id = mg.status_id;
        this.type_id = mg.type_id;
        this.amount = mg.amount;
        this.description = mg.description;
    }

当我尝试使用modelInvoice mas = new modelInvoice(VALUES)时,似乎container_id数组和当前数组并不存储任何内容。

是初始化问题吗?我将List传递给container_id(包含数据,已检查)和List以显示(也检查了数据)。

我有点失落。

0 个答案:

没有答案