0
# User Data Model
1
2
Twitter user profile information including follower counts, verification status, profile details, and account metadata.
3
4
## Capabilities
5
6
### Users Class
7
8
Complete user profile data model representing Twitter user accounts with comprehensive profile information and metrics.
9
10
```java { .api }
11
/**
12
* Twitter user profile information including account details, metrics, and settings.
13
* Represents the complete user object from Twitter's REST API.
14
*/
15
public class Users {
16
17
/**
18
* Default constructor
19
*/
20
public Users();
21
22
/**
23
* Resets all fields to default values for object reuse
24
*/
25
public void reset();
26
27
// Basic user information
28
/**
29
* Gets the user's screen name (username without @)
30
* @return Screen name as string
31
*/
32
public String getScreen_name();
33
34
/**
35
* Sets the user's screen name
36
* @param screen_name - Screen name
37
*/
38
public void setScreen_name(String screen_name);
39
40
/**
41
* Gets the user's display name
42
* @return Display name as string
43
*/
44
public String getName();
45
46
/**
47
* Sets the user's display name
48
* @param name - Display name
49
*/
50
public void setName(String name);
51
52
/**
53
* Gets the unique user ID
54
* @return User ID as long
55
*/
56
public long getId();
57
58
/**
59
* Sets the unique user ID
60
* @param id - User ID
61
*/
62
public void setId(long id);
63
64
/**
65
* Gets the user ID as string representation
66
* @return User ID as string (computed from long ID)
67
*/
68
public String getId_str();
69
70
/**
71
* Sets the user ID as string
72
* @param id_str - User ID string
73
*/
74
public void setId_str(String id_str);
75
76
/**
77
* Gets the user's profile description/bio
78
* @return Description text
79
*/
80
public String getDescription();
81
82
/**
83
* Sets the user's profile description/bio
84
* @param description - Description text
85
*/
86
public void setDescription(String description);
87
88
/**
89
* Gets the user's location information
90
* @return Location string as entered by user
91
*/
92
public String getLocation();
93
94
/**
95
* Sets the user's location information
96
* @param location - Location string
97
*/
98
public void setLocation(String location);
99
100
/**
101
* Gets the user's profile URL
102
* @return URL string
103
*/
104
public String getUrl();
105
106
/**
107
* Sets the user's profile URL
108
* @param url - URL string
109
*/
110
public void setUrl(String url);
111
112
/**
113
* Gets the user's account creation timestamp
114
* @return Creation timestamp in Twitter format
115
*/
116
public String getCreated_at();
117
118
/**
119
* Sets the user's account creation timestamp
120
* @param created_at - Creation timestamp
121
*/
122
public void setCreated_at(String created_at);
123
124
/**
125
* Gets the user's language preference
126
* @return Language code (e.g., "en", "es")
127
*/
128
public String getLang();
129
130
/**
131
* Sets the user's language preference
132
* @param lang - Language code
133
*/
134
public void setLang(String lang);
135
136
// User metrics
137
/**
138
* Gets the number of followers
139
* @return Follower count as long
140
*/
141
public long getFollowers_count();
142
143
/**
144
* Sets the number of followers
145
* @param followers_count - Follower count
146
*/
147
public void setFollowers_count(long followers_count);
148
149
/**
150
* Gets the number of accounts this user follows
151
* @return Following count as long
152
*/
153
public long getFriends_count();
154
155
/**
156
* Sets the number of accounts this user follows
157
* @param friends_count - Following count
158
*/
159
public void setFriends_count(long friends_count);
160
161
/**
162
* Gets the total number of tweets posted by this user
163
* @return Tweet count as long
164
*/
165
public long getStatuses_count();
166
167
/**
168
* Sets the total number of tweets posted by this user
169
* @param statuses_count - Tweet count
170
*/
171
public void setStatuses_count(long statuses_count);
172
173
/**
174
* Gets the number of lists this user is included in
175
* @return Listed count as long
176
*/
177
public long getListed_count();
178
179
/**
180
* Sets the number of lists this user is included in
181
* @param listed_count - Listed count
182
*/
183
public void setListed_count(long listed_count);
184
185
/**
186
* Gets the number of tweets this user has favorited
187
* @return Favorites count as long
188
*/
189
public long getFavourites_count();
190
191
/**
192
* Sets the number of tweets this user has favorited
193
* @param favourites_count - Favorites count
194
*/
195
public void setFavourites_count(long favourites_count);
196
197
// Account status and verification
198
/**
199
* Checks if the user account is verified
200
* @return true if verified account
201
*/
202
public boolean isVerified();
203
204
/**
205
* Sets the verification status
206
* @param verified - true if verified account
207
*/
208
public void setVerified(boolean verified);
209
210
/**
211
* Checks if the user's tweets are protected (private)
212
* @return true if tweets are protected
213
*/
214
public boolean isProtected_tweet();
215
216
/**
217
* Sets the protected status for user's tweets
218
* @param protected_tweet - true if tweets are protected
219
*/
220
public void setProtected_tweet(boolean protected_tweet);
221
222
/**
223
* Checks if geo-location is enabled for this user
224
* @return true if geo-location enabled
225
*/
226
public boolean isGeo_enabled();
227
228
/**
229
* Sets the geo-location enabled status
230
* @param geo_enabled - true if geo-location enabled
231
*/
232
public void setGeo_enabled(boolean geo_enabled);
233
234
/**
235
* Checks if the user is a translator
236
* @return true if user is a translator
237
*/
238
public boolean isIs_translator();
239
240
/**
241
* Sets the translator status
242
* @param is_translator - true if user is a translator
243
*/
244
public void setIs_translator(boolean is_translator);
245
246
/**
247
* Checks if contributors are enabled for this user
248
* @return true if contributors enabled
249
*/
250
public boolean isContributors_enabled();
251
252
/**
253
* Sets the contributors enabled status
254
* @param contributors_enabled - true if contributors enabled
255
*/
256
public void setContributors_enabled(boolean contributors_enabled);
257
258
// Profile appearance
259
/**
260
* Gets the profile background color
261
* @return Background color as hex string
262
*/
263
public String getProfile_background_color();
264
265
/**
266
* Sets the profile background color
267
* @param profile_background_color - Background color hex string
268
*/
269
public void setProfile_background_color(String profile_background_color);
270
271
/**
272
* Gets the profile background image URL
273
* @return Background image URL
274
*/
275
public String getProfile_background_image_url();
276
277
/**
278
* Sets the profile background image URL
279
* @param profile_background_image_url - Background image URL
280
*/
281
public void setProfile_background_image_url(String profile_background_image_url);
282
283
/**
284
* Gets the HTTPS profile background image URL
285
* @return HTTPS background image URL
286
*/
287
public String getProfile_background_image_url_https();
288
289
/**
290
* Sets the HTTPS profile background image URL
291
* @param profile_background_image_url_https - HTTPS background image URL
292
*/
293
public void setProfile_background_image_url_https(String profile_background_image_url_https);
294
295
/**
296
* Checks if background image is tiled
297
* @return true if background image is tiled
298
*/
299
public boolean isProfile_background_tile();
300
301
/**
302
* Sets the background image tiling
303
* @param profile_background_tile - true if background image is tiled
304
*/
305
public void setProfile_background_tile(boolean profile_background_tile);
306
307
/**
308
* Gets the profile image URL
309
* @return Profile image URL
310
*/
311
public String getProfile_image_url();
312
313
/**
314
* Sets the profile image URL
315
* @param profile_image_url - Profile image URL
316
*/
317
public void setProfile_image_url(String profile_image_url);
318
319
/**
320
* Gets the HTTPS profile image URL
321
* @return HTTPS profile image URL
322
*/
323
public String getProfile_image_url_https();
324
325
/**
326
* Sets the HTTPS profile image URL
327
* @param profile_image_url_https - HTTPS profile image URL
328
*/
329
public void setProfile_image_url_https(String profile_image_url_https);
330
331
/**
332
* Gets the profile banner URL
333
* @return Profile banner URL
334
*/
335
public String getProfile_banner_url();
336
337
/**
338
* Sets the profile banner URL
339
* @param profile_banner_url - Profile banner URL
340
*/
341
public void setProfile_banner_url(String profile_banner_url);
342
343
/**
344
* Gets the profile link color
345
* @return Link color as hex string
346
*/
347
public String getProfile_link_color();
348
349
/**
350
* Sets the profile link color
351
* @param profile_link_color - Link color hex string
352
*/
353
public void setProfile_link_color(String profile_link_color);
354
355
/**
356
* Gets the profile sidebar border color
357
* @return Sidebar border color as hex string
358
*/
359
public String getProfile_sidebar_border_color();
360
361
/**
362
* Sets the profile sidebar border color
363
* @param profile_sidebar_border_color - Sidebar border color hex string
364
*/
365
public void setProfile_sidebar_border_color(String profile_sidebar_border_color);
366
367
/**
368
* Gets the profile sidebar fill color
369
* @return Sidebar fill color as hex string
370
*/
371
public String getProfile_sidebar_fill_color();
372
373
/**
374
* Sets the profile sidebar fill color
375
* @param profile_sidebar_fill_color - Sidebar fill color hex string
376
*/
377
public void setProfile_sidebar_fill_color(String profile_sidebar_fill_color);
378
379
/**
380
* Gets the profile text color
381
* @return Text color as hex string
382
*/
383
public String getProfile_text_color();
384
385
/**
386
* Sets the profile text color
387
* @param profile_text_color - Text color hex string
388
*/
389
public void setProfile_text_color(String profile_text_color);
390
391
/**
392
* Checks if background image is used in profile
393
* @return true if background image is used
394
*/
395
public boolean isProfile_use_background_image();
396
397
/**
398
* Sets whether to use background image in profile
399
* @param profile_use_background_image - true to use background image
400
*/
401
public void setProfile_use_background_image(boolean profile_use_background_image);
402
403
/**
404
* Checks if using default profile settings
405
* @return true if using default profile
406
*/
407
public boolean isDefault_profile();
408
409
/**
410
* Sets the default profile status
411
* @param default_profile - true if using default profile
412
*/
413
public void setDefault_profile(boolean default_profile);
414
415
/**
416
* Checks if using default profile image
417
* @return true if using default profile image
418
*/
419
public boolean isDefault_profile_image();
420
421
/**
422
* Sets the default profile image status
423
* @param default_profile_image - true if using default profile image
424
*/
425
public void setDefault_profile_image(boolean default_profile_image);
426
427
// Relationship status (from current user's perspective)
428
/**
429
* Checks if current user is following this user
430
* @return true if following
431
*/
432
public boolean isFollowing();
433
434
/**
435
* Sets the following status
436
* @param following - true if following
437
*/
438
public void setFollowing(boolean following);
439
440
/**
441
* Checks if current user has sent a follow request to this user
442
* @return true if follow request sent
443
*/
444
public boolean isFollow_request_sent();
445
446
/**
447
* Sets the follow request sent status
448
* @param follow_request_sent - true if follow request sent
449
*/
450
public void setFollow_request_sent(boolean follow_request_sent);
451
452
/**
453
* Checks if notifications are enabled for this user
454
* @return true if notifications enabled
455
*/
456
public boolean isNotifications();
457
458
/**
459
* Sets the notifications enabled status
460
* @param notifications - true if notifications enabled
461
*/
462
public void setNotifications(boolean notifications);
463
464
// Timezone information
465
/**
466
* Gets the user's timezone
467
* @return Timezone string
468
*/
469
public String getTime_zone();
470
471
/**
472
* Sets the user's timezone
473
* @param time_zone - Timezone string
474
*/
475
public void setTime_zone(String time_zone);
476
477
/**
478
* Gets the UTC offset in seconds
479
* @return UTC offset as long
480
*/
481
public long getUtc_offset();
482
483
/**
484
* Sets the UTC offset in seconds
485
* @param utc_offset - UTC offset
486
*/
487
public void setUtc_offset(long utc_offset);
488
489
// Additional entities
490
/**
491
* Gets the entities extracted from user profile fields
492
* @return Entities object containing URLs, mentions from profile
493
*/
494
public Entities getEntities();
495
496
/**
497
* Sets the entities extracted from user profile fields
498
* @param entities - Entities object
499
*/
500
public void setEntities(Entities entities);
501
}
502
```
503
504
**Usage Examples:**
505
506
```java
507
import org.apache.flink.contrib.tweetinputformat.model.User.Users;
508
import org.apache.flink.contrib.tweetinputformat.model.tweet.Tweet;
509
510
// Access user information from tweets
511
DataSet<Tweet> tweets = env.readFile(new SimpleTweetInputFormat(), "tweets.json");
512
513
// Extract verified users
514
DataSet<Users> verifiedUsers = tweets
515
.filter(tweet -> tweet.getUser().isVerified())
516
.map(tweet -> tweet.getUser())
517
.distinct(user -> user.getId());
518
519
// Analyze user engagement
520
DataSet<Tuple3<String, Long, Long>> userMetrics = tweets
521
.map(tweet -> {
522
Users user = tweet.getUser();
523
return new Tuple3<>(
524
user.getScreen_name(),
525
user.getFollowers_count(),
526
user.getStatuses_count()
527
);
528
});
529
530
// Find influential users (high follower-to-following ratio)
531
DataSet<String> influentialUsers = tweets
532
.map(tweet -> tweet.getUser())
533
.filter(user -> user.getFollowers_count() > user.getFriends_count() * 10)
534
.map(user -> user.getScreen_name());
535
```
536
537
```java
538
// User profile analysis
539
Tweet tweet = new Tweet();
540
// Tweet populated by input format...
541
542
Users user = tweet.getUser();
543
544
// Basic user info
545
System.out.println("User: @" + user.getScreen_name());
546
System.out.println("Name: " + user.getName());
547
System.out.println("Bio: " + user.getDescription());
548
System.out.println("Location: " + user.getLocation());
549
550
// User metrics
551
System.out.println("Followers: " + user.getFollowers_count());
552
System.out.println("Following: " + user.getFriends_count());
553
System.out.println("Tweets: " + user.getStatuses_count());
554
System.out.println("Listed: " + user.getListed_count());
555
556
// Account status
557
if (user.isVerified()) {
558
System.out.println("β Verified account");
559
}
560
if (user.isProtected_tweet()) {
561
System.out.println("π Protected tweets");
562
}
563
564
// Profile customization
565
if (!user.isDefault_profile()) {
566
System.out.println("Profile colors: bg=" + user.getProfile_background_color() +
567
", link=" + user.getProfile_link_color());
568
}
569
```
570
571
**Key Features:**
572
573
- **Complete Twitter User Schema**: All fields from Twitter REST API user objects
574
- **Engagement Metrics**: Follower counts, tweet counts, favorites, and lists
575
- **Verification Status**: Account verification and protection settings
576
- **Profile Customization**: Colors, images, and appearance settings
577
- **Relationship Data**: Following status from current user's perspective
578
- **Geographic Settings**: Timezone and geo-location preferences
579
- **Object Reuse**: Reset functionality for memory-efficient processing