1package im.conversations.android.xmpp.model.avatar;
2
3import com.google.common.base.Strings;
4import eu.siacs.conversations.xml.Namespace;
5import im.conversations.android.annotation.XmlElement;
6import im.conversations.android.xmpp.model.Extension;
7import okhttp3.HttpUrl;
8
9@XmlElement(namespace = Namespace.AVATAR_METADATA)
10public class Info extends Extension {
11
12 public Info() {
13 super(Info.class);
14 }
15
16 public Info(
17 final String id,
18 final long bytes,
19 final String type,
20 final int height,
21 final int width) {
22 this();
23 this.setId(id);
24 this.setBytes(bytes);
25 this.setType(type);
26 this.setHeight(height);
27 this.setWidth(width);
28 }
29
30 public long getHeight() {
31 return this.getLongAttribute("height");
32 }
33
34 public long getWidth() {
35 return this.getLongAttribute("width");
36 }
37
38 public long getBytes() {
39 return this.getLongAttribute("bytes");
40 }
41
42 public String getType() {
43 return this.getAttribute("type");
44 }
45
46 public HttpUrl getUrl() {
47 final var url = this.getAttribute("url");
48 if (Strings.isNullOrEmpty(url)) {
49 return null;
50 }
51 return HttpUrl.parse(url);
52 }
53
54 public String getId() {
55 return this.getAttribute("id");
56 }
57
58 public void setBytes(final long size) {
59 this.setAttribute("bytes", size);
60 }
61
62 public void setId(final String id) {
63 this.setAttribute("id", id);
64 }
65
66 public void setHeight(final long height) {
67 this.setAttribute("height", height);
68 }
69
70 public void setWidth(final long width) {
71 this.setAttribute("width", width);
72 }
73
74 public void setType(final String type) {
75 this.setAttribute("type", type);
76 }
77
78 public void setUrl(final HttpUrl url) {
79 this.setAttribute("url", url.toString());
80 }
81}