package com.phlx.wool.entity;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.databinding.BaseObservable;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;

/**
 * <pre>
 *     author : lei
 *     e-mail : 18600395998@163.com
 *     time   : 2020/04/10
 *     desc   : 发标记录表
 *     version: 1.0
 * </pre>
 */
@Entity
public class Label extends BaseObservable implements Parcelable {

    @Id(autoincrement = false)
    @Expose(serialize = false, deserialize = true)
    private Long id;

    /**
     * 养殖单位
     */
    @SerializedName("preflagunit")
    private String receivingUnit;

    /**
     * 耳标EPC
     */
    @SerializedName("slugno")
    private String Epc;

    /**
     * 二维码
     */
    @SerializedName("twodimensionno")
    private String twodimensionno;

    /**
     * 耳标tid
     */
    @Index(name = "LabelTid", unique = true)
    @SerializedName("innercode")
    private String Tid;

    /**
     * 合法状态 0 非法 1 合法
     */
    @SerializedName("errorstate")
    private String isLegalStatus;


    /**
     * 时间戳
     */
    @Index(name = "labelTime")
    @SerializedName("inputTime")
    private long timestamp;


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.receivingUnit);
        dest.writeString(this.Epc);
        dest.writeString(this.twodimensionno);
        dest.writeString(this.Tid);
        dest.writeString(this.isLegalStatus);
        dest.writeLong(this.timestamp);
    }

    public Long getId() {
        return this.id;
    }

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

    public String getReceivingUnit() {
        return this.receivingUnit;
    }

    public void setReceivingUnit(String receivingUnit) {
        this.receivingUnit = receivingUnit;
    }

    public String getEpc() {
        return this.Epc;
    }

    public void setEpc(String Epc) {
        this.Epc = Epc;
    }

    public String getTwodimensionno() {
        return this.twodimensionno;
    }

    public void setTwodimensionno(String twodimensionno) {
        this.twodimensionno = twodimensionno;
    }

    public String getTid() {
        return this.Tid;
    }

    public void setTid(String Tid) {
        this.Tid = Tid;
    }

    public String getIsLegalStatus() {
        return this.isLegalStatus;
    }

    public void setIsLegalStatus(String isLegalStatus) {
        this.isLegalStatus = isLegalStatus;
    }

    public long getTimestamp() {
        return this.timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public Label() {
    }

    protected Label(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.receivingUnit = in.readString();
        this.Epc = in.readString();
        this.twodimensionno = in.readString();
        this.Tid = in.readString();
        this.isLegalStatus = in.readString();
        this.timestamp = in.readLong();
    }

    @Generated(hash = 643225198)
    public Label(Long id, String receivingUnit, String Epc, String twodimensionno,
            String Tid, String isLegalStatus, long timestamp) {
        this.id = id;
        this.receivingUnit = receivingUnit;
        this.Epc = Epc;
        this.twodimensionno = twodimensionno;
        this.Tid = Tid;
        this.isLegalStatus = isLegalStatus;
        this.timestamp = timestamp;
    }

    public static final Creator<Label> CREATOR = new Creator<Label>() {
        @Override
        public Label createFromParcel(Parcel source) {
            return new Label(source);
        }

        @Override
        public Label[] newArray(int size) {
            return new Label[size];
        }
    };

    @Override
    public String toString() {
        return "Label{" +
                "id=" + id +
                ", receivingUnit='" + receivingUnit + '\'' +
                ", Epc='" + Epc + '\'' +
                ", twodimensionno='" + twodimensionno + '\'' +
                ", Tid='" + Tid + '\'' +
                ", isLegalStatus='" + isLegalStatus + '\'' +
                ", timestamp=" + timestamp +
                '}';
    }
}
