Skip to content

Commit cd4fc2c

Browse files
kbhardwaj123maskaravivek
authored andcommitted
CategoryItem: add javadocs to the file (#3332)
1 parent c682ba8 commit cd4fc2c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

app/src/main/java/fr/free/nrw/commons/category/CategoryItem.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import android.os.Parcel;
44
import android.os.Parcelable;
55

6+
/**
7+
* Represents a Category Item.
8+
* Implemented as Parcelable so that its object could be parsed between activity components.
9+
*/
610
public class CategoryItem implements Parcelable {
711
private final String name;
812
private boolean selected;
@@ -24,28 +28,53 @@ public CategoryItem(String name, boolean selected) {
2428
this.selected = selected;
2529
}
2630

31+
/**
32+
* Reads from the received Parcel
33+
* @param in
34+
*/
2735
private CategoryItem(Parcel in) {
2836
name = in.readString();
2937
selected = in.readInt() == 1;
3038
}
3139

40+
/**
41+
* Gets Name
42+
* @return
43+
*/
3244
public String getName() {
3345
return name;
3446
}
3547

48+
/**
49+
* Checks if that Category Item has been selected.
50+
* @return
51+
*/
3652
public boolean isSelected() {
3753
return selected;
3854
}
3955

56+
/**
57+
* Selects the Category Item.
58+
* @param selected
59+
*/
4060
public void setSelected(boolean selected) {
4161
this.selected = selected;
4262
}
4363

64+
/**
65+
* Used by Parcelable
66+
* @return
67+
*/
4468
@Override
4569
public int describeContents() {
4670
return 0;
4771
}
4872

73+
/**
74+
* Writes to the received Parcel
75+
* @param parcel
76+
* @param flags
77+
*/
4978
@Override
5079
public void writeToParcel(Parcel parcel, int flags) {
5180
parcel.writeString(name);
@@ -67,11 +96,17 @@ public boolean equals(Object o) {
6796

6897
}
6998

99+
/**
100+
* Returns hash code for current object
101+
*/
70102
@Override
71103
public int hashCode() {
72104
return name.hashCode();
73105
}
74106

107+
/**
108+
* Return String form of current object
109+
*/
75110
@Override
76111
public String toString() {
77112
return "CategoryItem: '" + name + '\'';

0 commit comments

Comments
 (0)