package openfoodfacts.github.scrachx.openfood.models;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.orm.SugarRecord;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
        "code",
        "name",
        "risk"
})
public class Additive extends SugarRecord {

    private String code;
    private String name;
    private String risk;

    protected Additive(){}

    public Additive(String code, String name, String risk) {
        this.code = code.toUpperCase();
        this.name = name;
        this.risk = risk;
    }

    /**
     *
     * @return
     * The code
     */
    public String getCode() {
        return code;
    }

    /**
     *
     * @param code
     * The code
     */
    public void setCode(String code) {
        this.code = code.toUpperCase();
    }

    /**
     *
     * @return
     * The name
     */
    public String getName() {
        return name;
    }

    /**
     *
     * @param name
     * The name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     *
     * @return
     * The risk
     */
    public String getRisk() {
        return risk;
    }

    /**
     *
     * @param risk
     * The risk
     */
    public void setRisk(String risk) {
        this.risk = risk;
    }

    @Override
    public String toString() {
        return "Additive{" +
                "code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", risk='" + risk + '\'' +
                '}';
    }
}

@@ -433,16 +433,13 @@
    p
-rotected
+ublic
  Add
@@ -1576,11 +1576,400 @@
 ';%0A    %7D
+%0A%0A    @Override%0A    public boolean equals(Object o) %7B%0A        if (this == o) return true;%0A        if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A        Additive additive = (Additive) o;%0A%0A        return code != null ? code.equals(additive.code) : additive.code == null;%0A%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return code != null ? code.hashCode() : 0;%0A    %7D
 %0A%7D%0A

add equals/hashcode methods on the Additive entity to avoid duplicates in the DB