This repository was archived by the owner on Jan 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathIm.java
More file actions
385 lines (329 loc) · 9.17 KB
/
Copy pathIm.java
File metadata and controls
385 lines (329 loc) · 9.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/* Copyright (c) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gdata.model.gd;
import com.google.gdata.model.AttributeKey;
import com.google.gdata.model.Element;
import com.google.gdata.model.ElementCreator;
import com.google.gdata.model.ElementKey;
import com.google.gdata.model.MetadataRegistry;
import com.google.gdata.model.QName;
import com.google.gdata.util.Namespaces;
/**
* Describes an instant messaging address.
*
*
*/
public class Im extends Element {
/** Im protocol. */
public static final class Protocol {
/** AIM. */
public static final String AIM = Namespaces.gPrefix + "AIM";
/** Google Talk. */
public static final String GOOGLE_TALK = Namespaces.gPrefix + "GOOGLE_TALK";
/** ICQ. */
public static final String ICQ = Namespaces.gPrefix + "ICQ";
/** Jabber. */
public static final String JABBER = Namespaces.gPrefix + "JABBER";
/** MSN. */
public static final String MSN = Namespaces.gPrefix + "MSN";
/** NetMeeting. */
public static final String NETMEETING = Namespaces.gPrefix + "NETMEETING";
/** Tencent QQ. */
public static final String QQ = Namespaces.gPrefix + "QQ";
/** Skype. */
public static final String SKYPE = Namespaces.gPrefix + "SKYPE";
/** Yahoo. */
public static final String YAHOO = Namespaces.gPrefix + "YAHOO";
/** Array containing all available values. */
private static final String[] ALL_VALUES = {
AIM,
GOOGLE_TALK,
ICQ,
JABBER,
MSN,
NETMEETING,
QQ,
SKYPE,
YAHOO};
/** Returns an array of all values defined in this class. */
public static String[] values() {
return ALL_VALUES;
}
private Protocol() {}
}
/** Im type. */
public static final class Rel {
/** Home instant messaging address. */
public static final String HOME = Namespaces.gPrefix + "home";
/** Other instant messaging address. */
public static final String OTHER = Namespaces.gPrefix + "other";
/** Work instant messaging address. */
public static final String WORK = Namespaces.gPrefix + "work";
/** Array containing all available values. */
private static final String[] ALL_VALUES = {
HOME,
OTHER,
WORK};
/** Returns an array of all values defined in this class. */
public static String[] values() {
return ALL_VALUES;
}
private Rel() {}
}
/**
* The key for this element.
*/
public static final ElementKey<Void,
Im> KEY = ElementKey.of(new QName(Namespaces.gNs, "im"), Void.class,
Im.class);
/**
* IM address.
*/
public static final AttributeKey<String> ADDRESS = AttributeKey.of(new
QName(null, "address"), String.class);
/**
* Label.
*/
public static final AttributeKey<String> LABEL = AttributeKey.of(new
QName(null, "label"), String.class);
/**
* Whether this is the primary instant messaging address.
*/
public static final AttributeKey<Boolean> PRIMARY = AttributeKey.of(new
QName(null, "primary"), Boolean.class);
/**
* Im protocol.
*/
public static final AttributeKey<String> PROTOCOL = AttributeKey.of(new
QName(null, "protocol"), String.class);
/**
* Im type.
*/
public static final AttributeKey<String> REL = AttributeKey.of(new QName(null,
"rel"), String.class);
/**
* Registers the metadata for this element.
*/
public static void registerMetadata(MetadataRegistry registry) {
if (registry.isRegistered(KEY)) {
return;
}
// The builder for this element
ElementCreator builder = registry.build(KEY);
// Local properties
builder.addAttribute(ADDRESS).setRequired(true);
builder.addAttribute(LABEL);
builder.addAttribute(PRIMARY);
builder.addAttribute(PROTOCOL);
builder.addAttribute(REL);
}
/**
* Constructs an instance using the default key.
*/
public Im() {
super(KEY);
}
/**
* Subclass constructor, allows subclasses to supply their own element key.
*/
protected Im(ElementKey<?, ? extends Im> key) {
super(key);
}
/**
* Constructs a new instance by doing a shallow copy of data from an existing
* {@link Element} instance. Will use the given {@link ElementKey} as the key
* for the element. This constructor is used when adapting from one element
* key to another. You cannot call this constructor directly, instead use
* {@link Element#createElement(ElementKey, Element)}.
*
* @param key The key to use for this element.
* @param source source element
*/
protected Im(ElementKey<?, ? extends Im> key, Element source) {
super(key, source);
}
@Override
public Im lock() {
return (Im) super.lock();
}
/**
* Returns the IM address.
*
* @return IM address
*/
public String getAddress() {
return super.getAttributeValue(ADDRESS);
}
/**
* Sets the IM address.
*
* @param address IM address or {@code null} to reset
* @return this to enable chaining setters
*/
public Im setAddress(String address) {
super.setAttributeValue(ADDRESS, address);
return this;
}
/**
* Returns whether it has the IM address.
*
* @return whether it has the IM address
*/
public boolean hasAddress() {
return super.hasAttribute(ADDRESS);
}
/**
* Returns the label.
*
* @return label
*/
public String getLabel() {
return super.getAttributeValue(LABEL);
}
/**
* Sets the label.
*
* @param label label or {@code null} to reset
* @return this to enable chaining setters
*/
public Im setLabel(String label) {
super.setAttributeValue(LABEL, label);
return this;
}
/**
* Returns whether it has the label.
*
* @return whether it has the label
*/
public boolean hasLabel() {
return super.hasAttribute(LABEL);
}
/**
* Returns the whether this is the primary instant messaging address.
*
* @return whether this is the primary instant messaging address
*/
public Boolean getPrimary() {
return super.getAttributeValue(PRIMARY);
}
/**
* Sets the whether this is the primary instant messaging address.
*
* @param primary whether this is the primary instant messaging address or
* {@code null} to reset
* @return this to enable chaining setters
*/
public Im setPrimary(Boolean primary) {
super.setAttributeValue(PRIMARY, primary);
return this;
}
/**
* Returns whether it has the whether this is the primary instant messaging
* address.
*
* @return whether it has the whether this is the primary instant messaging
* address
*/
public boolean hasPrimary() {
return super.hasAttribute(PRIMARY);
}
/**
* Returns the im protocol.
*
* @return im protocol
*/
public String getProtocol() {
return super.getAttributeValue(PROTOCOL);
}
/**
* Sets the im protocol.
*
* @param protocol im protocol or {@code null} to reset
* @return this to enable chaining setters
*/
public Im setProtocol(String protocol) {
super.setAttributeValue(PROTOCOL, protocol);
return this;
}
/**
* Returns whether it has the im protocol.
*
* @return whether it has the im protocol
*/
public boolean hasProtocol() {
return super.hasAttribute(PROTOCOL);
}
/**
* Returns the im type.
*
* @return im type
*/
public String getRel() {
return super.getAttributeValue(REL);
}
/**
* Sets the im type.
*
* @param rel im type or {@code null} to reset
* @return this to enable chaining setters
*/
public Im setRel(String rel) {
super.setAttributeValue(REL, rel);
return this;
}
/**
* Returns whether it has the im type.
*
* @return whether it has the im type
*/
public boolean hasRel() {
return super.hasAttribute(REL);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!sameClassAs(obj)) {
return false;
}
Im other = (Im) obj;
return eq(getAddress(), other.getAddress())
&& eq(getLabel(), other.getLabel())
&& eq(getPrimary(), other.getPrimary())
&& eq(getProtocol(), other.getProtocol())
&& eq(getRel(), other.getRel());
}
@Override
public int hashCode() {
int result = getClass().hashCode();
if (getAddress() != null) {
result = 37 * result + getAddress().hashCode();
}
if (getLabel() != null) {
result = 37 * result + getLabel().hashCode();
}
if (getPrimary() != null) {
result = 37 * result + getPrimary().hashCode();
}
if (getProtocol() != null) {
result = 37 * result + getProtocol().hashCode();
}
if (getRel() != null) {
result = 37 * result + getRel().hashCode();
}
return result;
}
}