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