package fyloz.trial.ColorRecipesExplorer.model;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "mixQuantities")
public class MixQuantity extends BeanModel implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic
    private Integer mixQuantityID = 0;

    @JsonIgnore
    @ManyToOne
    private Mix mix;

    @ManyToOne
    private Material material;

    @NotNull
    private Float quantity;

    public MixQuantity() {

    }

    public MixQuantity(Mix mix, Material material, @NotNull Float quantity) {
        this.mix = mix;
        this.material = material;
        this.quantity = quantity;
    }

    public Integer getMixQuantityID() {
        return mixQuantityID;
    }

    public void setMixQuantityID(Integer mixQuantityID) {
        this.mixQuantityID = mixQuantityID;
    }

    public Mix getMix() {
        return mix;
    }

    public void setMix(Mix mix) {
        this.mix = mix;
    }

    public Material getMaterial() {
        return material;
    }

    public void setMaterial(Material material) {
        this.material = material;
    }

    public Float getQuantity() {
        return quantity;
    }

    public void setQuantity(Float quantity) {
        this.quantity = quantity;
    }

    @Override
    public Integer getID() {
        return mixQuantityID;
    }

    @Override
    public String toString() {
        return "MixQuantity{" +
                "mixQuantityID=" + mixQuantityID +
                ", mix=" + mix +
                ", material=" + material +
                ", quantity=" + quantity +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MixQuantity that = (MixQuantity) o;
        return mixQuantityID.equals(that.mixQuantityID) &&
                quantity == that.quantity &&
                Objects.equals(mix, that.mix) &&
                Objects.equals(material, that.material);
    }
}
