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 {

    private int id;
    private int idServer;
    private String name;
    private String producent;
    private double price;
    private String kind;
    private Date dateExpiration;
    private long date;
    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> {

    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (obj == this) return true;
        if (!(obj instanceof Medicament))return false;
        Medicament medicament = (Medicament)obj;
        if(this.hashCode() == medicament.hashCode()) return true;
        else return false;
    }

    @Override
    public int hashCode() {
        int result = 17;
        int multipler = 31;
        //int
        result = multipler * result + idServer;
        result = multipler * result + productLineID;
        result = multipler * result + packageID;
        //String
        result = multipler * result + (name == null ? 0 : name.hashCode());
        result = multipler * result + (producent == null ? 0 : producent.hashCode());
        result = multipler * result + (kind == null ? 0 : kind.hashCode());
        //double
        long priceBits = Double.doubleToLongBits(price);
        result = multipler * result + (int)(priceBits ^ (priceBits >>> 32));

        result = multipler * result + (int)(priceBits ^ (priceBits >>> 32));

        return result;
    }

    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 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 getDateExpiration() {
        return dateExpiration;
    }

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

    public long getDate() {
        return date;
    }

    public void setDate(long date) {
        this.date = date;
    }

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

@@ -124,20 +124,72 @@
 va.util.
-Date
+Collection;%0Aimport java.util.Date;%0Aimport java.util.List
 ;%0A%0A/**%0A 
@@ -856,24 +856,24 @@
 ctLineID();%0A
-
         this
@@ -913,32 +913,903 @@
 ageID();%0A    %7D%0A%0A
+    public static Medicament containsId(Collection%3CMedicament%3E c, int id) %7B%0A        for(Medicament m : c) %7B%0A            if(m != null && m.getId() == id) %7B%0A                return m;%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%0A    public static java.util.List%3CMedicament%3E compareIdServer(java.util.List%3CMedicament%3E remoteMedicaments, java.util.List%3CMedicament%3E localMedicamentsSended) %7B%0A        java.util.List%3CMedicament%3E returnList = new ArrayList%3CMedicament%3E(remoteMedicaments);%0A        for (Medicament remoteMedicament : remoteMedicaments) %7B%0A            for (Medicament localMedicament : localMedicamentsSended) %7B%0A                if(localMedicament.getIdServer() == remoteMedicament.getIdServer()) %7B%0A                    returnList.remove(remoteMedicament);%0A                    break;%0A                %7D%0A%0A            %7D%0A%0A        %7D%0A        return returnList;%0A    %7D%0A%0A
     public stati
@@ -4523,16 +4523,47 @@
        %22
+id=%22 + id +%0A                %22, 
 idServer
@@ -4879,10 +4879,12 @@
 ;%0A    %7D%0A
+%0A%0A
 %7D%0A

add method compare two list by idserver