CategoryItem: add javadocs to the file (#3332)

This commit is contained in:
Kshitij Bhardwaj 2020-01-21 01:09:31 +05:30 committed by Vivek Maskara
parent c682ba83d7
commit cd4fc2cdf0

View file

@ -3,6 +3,10 @@ package fr.free.nrw.commons.category;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Represents a Category Item.
* Implemented as Parcelable so that its object could be parsed between activity components.
*/
public class CategoryItem implements Parcelable {
private final String name;
private boolean selected;
@ -24,28 +28,53 @@ public class CategoryItem implements Parcelable {
this.selected = selected;
}
/**
* Reads from the received Parcel
* @param in
*/
private CategoryItem(Parcel in) {
name = in.readString();
selected = in.readInt() == 1;
}
/**
* Gets Name
* @return
*/
public String getName() {
return name;
}
/**
* Checks if that Category Item has been selected.
* @return
*/
public boolean isSelected() {
return selected;
}
/**
* Selects the Category Item.
* @param selected
*/
public void setSelected(boolean selected) {
this.selected = selected;
}
/**
* Used by Parcelable
* @return
*/
@Override
public int describeContents() {
return 0;
}
/**
* Writes to the received Parcel
* @param parcel
* @param flags
*/
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeString(name);
@ -67,11 +96,17 @@ public class CategoryItem implements Parcelable {
}
/**
* Returns hash code for current object
*/
@Override
public int hashCode() {
return name.hashCode();
}
/**
* Return String form of current object
*/
@Override
public String toString() {
return "CategoryItem: '" + name + '\'';