summaryrefslogtreecommitdiff
path: root/src/data/Tweet.java
blob: 384a9e1c6db1a0b21a7555389c8cd271553a3644 (plain)
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
package data;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Represents the tweet object as returned by the twitter API.
 */
public class Tweet {

    public long id;
    public String lang;
    @ValidatingJsonDeserializer.Nullable
    public long in_reply_to_user_id;
    public String created_at;
    public long favorite_count;
    @ValidatingJsonDeserializer.Nullable
    @ValidatingJsonDeserializer.Validator
    public Place place;
    @ValidatingJsonDeserializer.Nullable
    public String coordinates;
    public String text;
    @ValidatingJsonDeserializer.Nullable
    @ValidatingJsonDeserializer.Validator
    public Tweet retweeted_status;
    @ValidatingJsonDeserializer.Validator
    public Entities entities;
    public long retweet_count;
    @ValidatingJsonDeserializer.Validator
    public User user;

    @Override
    public String toString() {
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(this);
    }

    public static class Place {

        //public String id; // "a5b6bdd8008412b1"
        //public String name; // "Danbury"
        //public String country_code; // "US"
        public String country; // "United States"
        //public String url; // "https://api.twitter.com/1.1/geo/id/a5b6bdd8008412b1.json"
        public String full_name; // "Danbury, CT"
    }

    public static class Entities {

        @ValidatingJsonDeserializer.Validator
        public Hashtag[] hashtags;
        @ValidatingJsonDeserializer.Validator
        public Url[] urls;
        @ValidatingJsonDeserializer.Validator
        public Mention[] user_mentions;
    }

    public static class Hashtag {

        public String text;
    }

    public static class Url {

        public String expanded_url;
        //public String display_url;
        //public String url;
    }

    public static class Mention {

        public long id; // user ID
        //public String name; // display name
        //public String screen_name; // Screen name (at-name)
    }
}