package local.tomo.login.model;

import android.util.Log;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by tomo on 2016-05-02.
 */
public class Medicament {

    DateExpirationYearMonth dateExpirationYearMonth = new DateExpirationYearMonth();

    private int id;
    private int idServer;
    private String name;
    private String producent;
    private double price;
    private String kind;
    private String dateExpiration;
    private Date dateFormatExpiration;
    private int productLineID;
    private int packageID;


    public Medicament() {
    }

    public Medicament(MedicamentDb medicamentDb) {
        this.name = medicamentDb.getProductName();
        this.producent = medicamentDb.getProducer();
        this.price = medicamentDb.getPrice();
        this.kind = medicamentDb.getPack();
        this.productLineID = medicamentDb.getProductLineID();
        this.packageID = medicamentDb.getPackageID();
    }

    public static class List extends ArrayList<Medicament> {

    }

    public void createDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(Long.parseLong(getDateExpiration()));
        calendar.add(Calendar.DAY_OF_MONTH,1);
        dateFormatExpiration = calendar.getTime();
    }

    public int getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getProducent() {
        return producent;
    }

    public void setProducent(String producent) {
        this.producent = producent;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getKind() {
        return kind;
    }

    public void setKind(String kind) {
        this.kind = kind;
    }

    public int getIdServer() {
        return idServer;
    }

    public void setIdServer(int idServer) {
        this.idServer = idServer;
    }

    public String getDateExpiration() {
        return dateExpiration;
    }

    public void setDateExpiration(String dateExpiration) {
        this.dateExpiration = dateExpiration;
    }

    public int getProductLineID() {
        return productLineID;
    }

    public void setProductLineID(int productLineID) {
        this.productLineID = productLineID;
    }

    public int getPackageID() {
        return packageID;
    }

    public void setPackageID(int packageID) {
        this.packageID = packageID;
    }

    public Date getDateFormatExpiration() {
        return dateFormatExpiration;
    }

    public void setDateFormatExpiration(Date dateFormatExpiration) {
        this.dateFormatExpiration = dateFormatExpiration;
    }

    public DateExpirationYearMonth getDateExpirationYearMonth() {
        return dateExpirationYearMonth;
    }

    public void setDateExpirationYearMonth(DateExpirationYearMonth dateExpirationYearMonth) {
        this.dateExpirationYearMonth = dateExpirationYearMonth;
    }

    @Override
    public String toString() {
        return "Medicament{" +
                "dateExpirationYearMonth=" + dateExpirationYearMonth +
                ", id=" + id +
                ", idServer=" + idServer +
                ", name='" + name + '\'' +
                ", producent='" + producent + '\'' +
                ", price=" + price +
                ", kind='" + kind + '\'' +
                ", dateExpiration='" + dateExpiration + '\'' +
                ", dateFormatExpiration=" + dateFormatExpiration +
                ", productLineID=" + productLineID +
                ", packageID=" + packageID +
                '}';
    }
}

@@ -1293,32 +1293,1159 @@
 tTime();%0A    %7D%0A%0A
+    @Override%0A    public boolean equals(Object obj) %7B%0A        if (obj == null) return false;%0A        if (obj == this) return true;%0A        if (!(obj instanceof Medicament))return false;%0A        Medicament medicament = (Medicament)obj;%0A        if(this.hashCode() == medicament.hashCode()) return true;%0A        else return false;%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        int result = 17;%0A        int multipler = 31;%0A        //int%0A        result = multipler * result + idServer;%0A        result = multipler * result + productLineID;%0A        result = multipler * result + packageID;%0A        //String%0A        result = multipler * result + (name == null ? 0 : name.hashCode());%0A        result = multipler * result + (producent == null ? 0 : producent.hashCode());%0A        result = multipler * result + (dateExpiration == null ? 0 : dateExpiration.hashCode());%0A        result = multipler * result + (kind == null ? 0 : kind.hashCode());%0A        //double%0A        long priceBits = Double.doubleToLongBits(price);%0A        result = multipler * result + (int)(priceBits %5E (priceBits %3E%3E%3E 32));%0A%0A        return result;%0A    %7D%0A%0A
     public int g
@@ -4363,112 +4363,8 @@
    %22
-dateExpirationYearMonth=%22 + dateExpirationYearMonth +%0A                %22, id=%22 + id +%0A                %22, 
 idSe
@@ -4626,75 +4626,8 @@
 ' +%0A
-                %22, dateFormatExpiration=%22 + dateFormatExpiration +%0A
     

add hashcode and equals to medicament