package fr.free.nrw.commons.category;

import android.os.Parcel;
import android.os.Parcelable;

public class CategoryItem implements Parcelable {
    private final String name;
    private boolean selected;

    public static Creator<CategoryItem> CREATOR = new Creator<CategoryItem>() {
        @Override
        public CategoryItem createFromParcel(Parcel parcel) {
            return new CategoryItem(parcel);
        }

        @Override
        public CategoryItem[] newArray(int i) {
            return new CategoryItem[0];
        }
    };

    public CategoryItem(String name, boolean selected) {
        this.name = name;
        this.selected = selected;
    }

    private CategoryItem(Parcel in) {
        name = in.readString();
        selected = in.readInt() == 1;
    }

    public String getName() {
        return name;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeString(name);
        parcel.writeInt(selected ? 1 : 0);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        CategoryItem that = (CategoryItem) o;

        return name.equals(that.name);

    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }

    @Override
    public String toString() {
        return "CategoryItem: '" + name + '\'';
    }
}

@@ -89,16 +89,148 @@
 lable;%0A%0A
+/**%0A * Represents a Category Item.%0A * Implemented as Parcelable so that its object could be parsed between activity components.%0A */%0A
 public c
@@ -793,24 +793,95 @@
 ted;%0A    %7D%0A%0A
+    /**%0A     * Reads from the received Parcel%0A     * @param in%0A     */%0A
     private 
@@ -975,32 +975,80 @@
 () == 1;%0A    %7D%0A%0A
+    /**%0A     * Gets Name%0A     * @return%0A     */%0A
     public Strin
@@ -1097,69 +1097,228 @@
     
-public boolean isSelected() %7B%0A        return selected;%0A    %7D%0A
+/**%0A     * Checks if that Category Item has been selected.%0A     * @return%0A     */%0A    public boolean isSelected() %7B%0A        return selected;%0A    %7D%0A%0A    /**%0A     * Selects the Category Item.%0A     * @param selected%0A     */
 %0A   
@@ -1395,32 +1395,89 @@
 elected;%0A    %7D%0A%0A
+    /**%0A     * Used by Parcelable%0A     * @return%0A     */%0A
     @Override%0A  
@@ -1527,32 +1527,126 @@
 eturn 0;%0A    %7D%0A%0A
+    /**%0A     * Writes to the received Parcel%0A     * @param parcel%0A     * @param flags%0A     */%0A
     @Override%0A  
@@ -2075,32 +2075,92 @@
 .name);%0A%0A    %7D%0A%0A
+    /**%0A     * Returns hash code for current object%0A     */%0A
     @Override%0A  
@@ -2216,32 +2216,92 @@
 hCode();%0A    %7D%0A%0A
+    /**%0A     * Return String form of current object%0A     */%0A
     @Override%0A  

add javadocs to the file (#3332)