package gruppn.kasslr.model;

import org.json.JSONException;
import org.json.JSONObject;

public class VocabularyItem {
    private int id;
    private String name;
    private String image;
    private long lastModified;
    private boolean mine = true;

    public VocabularyItem(String name, String imageName) {
        this.name = name;
        this.image = imageName;
    }

    public VocabularyItem(String name, String imageName, int id, boolean mine) {
        this(name, imageName);
        this.id = id;
        this.mine = mine;
    }

    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.trim();
    }

    /**
     * @return The name of the image without file extension
     */
    public String getImageName() {
        return image;
    }

    public void setImageName(String image) {
        this.image = image;
    }

    public long getLastModified() {
        return lastModified;
    }

    public void setLastModified(long lastModified) {
        this.lastModified = lastModified;
    }

    public boolean isMine() {
        return mine;
    }

    public void setMine(boolean mine) {
        this.mine = mine;
    }

    public JSONObject toJSON() throws JSONException {
        JSONObject item = new JSONObject();
        item.put("Word", name);
        item.put("Picture", image);

        return item;
    }

    @Override
    public String toString() {
        return "VocabularyItem{"
                + "name=" + name
                + ",image=" + image
                + ",mine=" + mine
                + "}";
    }
}

@@ -1306,32 +1306,928 @@
  = mine;%0A    %7D%0A%0A
+    @Override%0A    public boolean equals(Object o) %7B%0A        if (this == o) return true;%0A        if (!(o instanceof VocabularyItem)) return false;%0A%0A        VocabularyItem that = (VocabularyItem) o;%0A%0A        if (getId() != that.getId()) return false;%0A        if (isMine() != that.isMine()) return false;%0A        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null)%0A            return false;%0A        return image != null ? image.equals(that.image) : that.image == null;%0A%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        int result = getId();%0A        result = 31 * result + (getName() != null ? getName().hashCode() : 0);%0A        result = 31 * result + (image != null ? image.hashCode() : 0);%0A        result = 31 * result + (int) (getLastModified() %5E (getLastModified() %3E%3E%3E 32));%0A        result = 31 * result + (isMine() ? 1 : 0);%0A        return result;%0A    %7D%0A%0A
     public JSONO
@@ -2615,10 +2615,12 @@
 ;%0A    %7D%0A
+%0A%0A
 %7D%0A

add equals method so that gallery from camera is working