ListItem.java

 1package eu.siacs.conversations.entities;
 2
 3import android.content.Context;
 4
 5import java.io.Serializable;
 6import java.util.List;
 7import java.util.Locale;
 8
 9import eu.siacs.conversations.services.AvatarService;
10import eu.siacs.conversations.xmpp.Jid;
11
12
13public interface ListItem extends Comparable<ListItem>, AvatarService.Avatarable {
14	String getDisplayName();
15
16	Jid getJid();
17
18	List<Tag> getTags(Context context);
19
20	final class Tag implements Serializable {
21		private final String name;
22		private final int color;
23
24		public Tag(final String name, final int color) {
25			this.name = name;
26			this.color = color;
27		}
28
29		public int getColor() {
30			return this.color;
31		}
32
33		public String getName() {
34			return this.name;
35		}
36
37		public String toString() {
38			return getName();
39		}
40
41		public boolean equals(Object o) {
42			if (!(o instanceof Tag)) return false;
43			Tag ot = (Tag) o;
44			return name.toLowerCase(Locale.US).equals(ot.getName().toLowerCase(Locale.US)) && color == ot.getColor();
45		}
46
47		public int hashCode() {
48			return name.toLowerCase(Locale.US).hashCode();
49		}
50	}
51
52	boolean match(Context context, final String needle);
53}