-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathIPResponseCore.java
More file actions
140 lines (119 loc) · 3.66 KB
/
IPResponseCore.java
File metadata and controls
140 lines (119 loc) · 3.66 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
package io.ipinfo.api.model;
import com.google.gson.annotations.SerializedName;
import io.ipinfo.api.context.Context;
public class IPResponseCore {
private final String ip;
private final Geo geo;
@SerializedName("as")
private final ASN asn;
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 IPResponseCore(
String ip,
Geo geo,
ASN asn,
Boolean is_anonymous,
Boolean is_anycast,
Boolean is_hosting,
Boolean is_mobile,
Boolean is_satellite
) {
this.ip = ip;
this.geo = geo;
this.asn = asn;
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 IPResponseCore(String ip, boolean bogon) {
this.ip = ip;
this.bogon = bogon;
this.geo = null;
this.asn = 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 Geo getGeo() {
return geo;
}
public ASN getAsn() {
return asn;
}
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 "IPResponseCore{" +
"ip='" + ip + '\'' +
", bogon=" + bogon +
'}';
}
return "IPResponseCore{" +
"ip='" + ip + '\'' +
", geo=" + geo +
", asn=" + asn +
", is_anonymous=" + is_anonymous +
", is_anycast=" + is_anycast +
", is_hosting=" + is_hosting +
", is_mobile=" + is_mobile +
", is_satellite=" + is_satellite +
'}';
}
}