-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathIPResponsePlus.java
More file actions
203 lines (175 loc) · 5.26 KB
/
IPResponsePlus.java
File metadata and controls
203 lines (175 loc) · 5.26 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
package io.ipinfo.api.model;
import com.google.gson.annotations.SerializedName;
import io.ipinfo.api.context.Context;
public class IPResponsePlus {
private final String ip;
private final String hostname;
private final GeoPlus geo;
@SerializedName("as")
private final ASNPlus asn;
private final Mobile mobile;
private final Anonymous anonymous;
private final Abuse abuse;
private final Company company;
private final Privacy privacy;
private final Domains domains;
private final Boolean is_anonymous;
private final Boolean is_anycast;
private final Boolean is_hosting;
private final Boolean is_mobile;
private final Boolean is_satellite;
private final boolean bogon;
private transient Context context;
public IPResponsePlus(
String ip,
String hostname,
GeoPlus geo,
ASNPlus asn,
Mobile mobile,
Anonymous anonymous,
Abuse abuse,
Company company,
Privacy privacy,
Domains domains,
Boolean is_anonymous,
Boolean is_anycast,
Boolean is_hosting,
Boolean is_mobile,
Boolean is_satellite
) {
this.ip = ip;
this.hostname = hostname;
this.geo = geo;
this.asn = asn;
this.mobile = mobile;
this.anonymous = anonymous;
this.abuse = abuse;
this.company = company;
this.privacy = privacy;
this.domains = domains;
this.is_anonymous = is_anonymous;
this.is_anycast = is_anycast;
this.is_hosting = is_hosting;
this.is_mobile = is_mobile;
this.is_satellite = is_satellite;
this.bogon = false;
}
public IPResponsePlus(String ip, boolean bogon) {
this.ip = ip;
this.bogon = bogon;
this.hostname = null;
this.geo = null;
this.asn = null;
this.mobile = null;
this.anonymous = null;
this.abuse = null;
this.company = null;
this.privacy = null;
this.domains = null;
this.is_anonymous = null;
this.is_anycast = null;
this.is_hosting = null;
this.is_mobile = null;
this.is_satellite = null;
}
/**
* Set by the library for extra utility functions
*
* @param context for country information
*/
public void setContext(Context context) {
this.context = context;
}
public String getIp() {
return ip;
}
public String getHostname() {
return hostname;
}
public GeoPlus getGeo() {
return geo;
}
public ASNPlus getAsn() {
return asn;
}
public Mobile getMobile() {
return mobile;
}
public Anonymous getAnonymous() {
return anonymous;
}
public Abuse getAbuse() {
return abuse;
}
public Company getCompany() {
return company;
}
public Privacy getPrivacy() {
return privacy;
}
public Domains getDomains() {
return domains;
}
public Boolean getIsAnonymous() {
return is_anonymous;
}
public Boolean getIsAnycast() {
return is_anycast;
}
public Boolean getIsHosting() {
return is_hosting;
}
public Boolean getIsMobile() {
return is_mobile;
}
public Boolean getIsSatellite() {
return is_satellite;
}
public boolean getBogon() {
return bogon;
}
public String getCountryName() {
return context != null && geo != null ? context.getCountryName(geo.getCountryCode()) : (geo != null ? geo.getCountry() : null);
}
public Boolean isEU() {
return context != null && geo != null ? context.isEU(geo.getCountryCode()) : null;
}
public CountryFlag getCountryFlag() {
return context != null && geo != null ? context.getCountryFlag(geo.getCountryCode()) : null;
}
public String getCountryFlagURL() {
return context != null && geo != null ? context.getCountryFlagURL(geo.getCountryCode()) : null;
}
public CountryCurrency getCountryCurrency() {
return context != null && geo != null ? context.getCountryCurrency(geo.getCountryCode()) : null;
}
public Continent getContinentInfo() {
return context != null && geo != null ? context.getContinent(geo.getCountryCode()) : null;
}
@Override
public String toString() {
if (bogon) {
return "IPResponsePlus{" +
"ip='" + ip + '\'' +
", bogon=" + bogon +
'}';
}
return "IPResponsePlus{" +
"ip='" + ip + '\'' +
", hostname='" + hostname + '\'' +
", geo=" + geo +
", asn=" + asn +
", mobile=" + mobile +
", anonymous=" + anonymous +
", abuse=" + abuse +
", company=" + company +
", privacy=" + privacy +
", domains=" + domains +
", is_anonymous=" + is_anonymous +
", is_anycast=" + is_anycast +
", is_hosting=" + is_hosting +
", is_mobile=" + is_mobile +
", is_satellite=" + is_satellite +
'}';
}
}