Skip to content

Commit 4166887

Browse files
committed
Refresh model classes
1 parent 0ecabf5 commit 4166887

23 files changed

+208
-239
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ CHANGELOG
44
2.17.0 (2023-11-21)
55
-------------------
66

7+
* Updated model classes with non-breaking changes from the 4.2.0
8+
branch. In particular, this fixes an issue deserializing the
9+
new `connection_type` from the GeoIP2 web services.
710
* Updated Jackson and `maxmind-db` dependencies.
811

912
2.16.1 (2021-11-18)

src/main/java/com/maxmind/geoip2/model/AbstractCityResponse.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ public abstract class AbstractCityResponse extends AbstractCountryResponse {
1919
}
2020

2121
AbstractCityResponse(
22-
City city,
23-
Continent continent,
24-
Country country,
25-
Location location,
26-
MaxMind maxmind,
27-
Postal postal,
28-
Country registeredCountry,
29-
RepresentedCountry representedCountry,
30-
List<Subdivision> subdivisions,
31-
Traits traits
22+
City city,
23+
Continent continent,
24+
Country country,
25+
Location location,
26+
MaxMind maxmind,
27+
Postal postal,
28+
Country registeredCountry,
29+
RepresentedCountry representedCountry,
30+
List<Subdivision> subdivisions,
31+
Traits traits
3232
) {
3333
super(continent, country, maxmind, registeredCountry, representedCountry, traits);
3434
this.city = city != null ? city : new City();
@@ -38,10 +38,10 @@ public abstract class AbstractCityResponse extends AbstractCountryResponse {
3838
}
3939

4040
AbstractCityResponse(
41-
AbstractCityResponse response,
42-
String ipAddress,
43-
Network network,
44-
List<String> locales
41+
AbstractCityResponse response,
42+
String ipAddress,
43+
Network network,
44+
List<String> locales
4545
) {
4646
super(response, ipAddress, network, locales);
4747
// The response fields will be non-null because of the above
@@ -53,8 +53,8 @@ public abstract class AbstractCityResponse extends AbstractCountryResponse {
5353
}
5454

5555
private static ArrayList<Subdivision> mapSubdivisions(
56-
List<Subdivision> subdivisions,
57-
List<String> locales
56+
List<Subdivision> subdivisions,
57+
List<String> locales
5858
) {
5959
ArrayList<Subdivision> subdivisions2 = new ArrayList<>(subdivisions.size());
6060
for (Subdivision subdivision : subdivisions) {

src/main/java/com/maxmind/geoip2/model/AbstractCountryResponse.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,27 @@ public abstract class AbstractCountryResponse extends AbstractResponse {
2020
}
2121

2222
AbstractCountryResponse(
23-
Continent continent,
24-
Country country,
25-
MaxMind maxmind,
26-
Country registeredCountry,
27-
RepresentedCountry representedCountry,
28-
Traits traits
23+
Continent continent,
24+
Country country,
25+
MaxMind maxmind,
26+
Country registeredCountry,
27+
RepresentedCountry representedCountry,
28+
Traits traits
2929
) {
3030
this.continent = continent != null ? continent : new Continent();
3131
this.country = country != null ? country : new Country();
3232
this.registeredCountry = registeredCountry != null ? registeredCountry : new Country();
3333
this.maxmind = maxmind != null ? maxmind : new MaxMind();
34-
this.representedCountry = representedCountry != null ? representedCountry : new RepresentedCountry();
34+
this.representedCountry =
35+
representedCountry != null ? representedCountry : new RepresentedCountry();
3536
this.traits = traits != null ? traits : new Traits();
3637
}
3738

3839
AbstractCountryResponse(
39-
AbstractCountryResponse response,
40-
String ipAddress,
41-
Network network,
42-
List<String> locales
40+
AbstractCountryResponse response,
41+
String ipAddress,
42+
Network network,
43+
List<String> locales
4344
) {
4445
// The response fields will be non-null because of the above
4546
// constructor used during deserializing.

src/main/java/com/maxmind/geoip2/model/AbstractResponse.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonInclude.Include;
44
import com.fasterxml.jackson.databind.MapperFeature;
5-
import com.fasterxml.jackson.databind.ObjectMapper;
65
import com.fasterxml.jackson.databind.json.JsonMapper;
7-
86
import java.io.IOException;
97

108
public abstract class AbstractResponse {
@@ -16,10 +14,10 @@ public abstract class AbstractResponse {
1614
*/
1715
public String toJson() throws IOException {
1816
JsonMapper mapper = JsonMapper.builder()
19-
.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)
20-
.serializationInclusion(Include.NON_NULL)
21-
.serializationInclusion(Include.NON_EMPTY)
22-
.build();
17+
.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)
18+
.serializationInclusion(Include.NON_NULL)
19+
.serializationInclusion(Include.NON_EMPTY)
20+
.build();
2321

2422
return mapper.writeValueAsString(this);
2523
}

src/main/java/com/maxmind/geoip2/model/AsnResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public String getIpAddress() {
102102

103103
/**
104104
* @return The network associated with the record. In particular, this is
105-
* the largest network where all of the fields besides IP address have the
105+
* the largest network where all the fields besides IP address have the
106106
* same value.
107107
*/
108108
@JsonProperty

src/main/java/com/maxmind/geoip2/model/CityResponse.java

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@
1111
import java.util.List;
1212

1313
/**
14-
* <p>
15-
* This class provides a model for the data returned by the GeoIP2 Precision:
16-
* City end point and the GeoIP2 City database.
17-
* </p>
18-
* <p>
19-
* The only difference between the City and Insights model classes is which
20-
* fields in each record may be populated.
21-
* </p>
22-
* <p>
14+
* This class provides a model for the data returned by the City Plus web
15+
* service and the City database.
2316
*
2417
* @see <a href="https://dev.maxmind.com/geoip/docs/web-services?lang=en">GeoIP2 Web
2518
* Services</a>
26-
* </p>
2719
*/
2820
public final class CityResponse extends AbstractCityResponse {
2921

@@ -33,26 +25,30 @@ public final class CityResponse extends AbstractCityResponse {
3325

3426
@MaxMindDbConstructor
3527
public CityResponse(
36-
@JsonProperty("city") @MaxMindDbParameter(name="city") City city,
37-
@JsonProperty("continent") @MaxMindDbParameter(name="continent") Continent continent,
38-
@JsonProperty("country") @MaxMindDbParameter(name="country") Country country,
39-
@JsonProperty("location") @MaxMindDbParameter(name="location") Location location,
40-
@JsonProperty("maxmind") @MaxMindDbParameter(name="maxmind") MaxMind maxmind,
41-
@JsonProperty("postal") @MaxMindDbParameter(name="postal") Postal postal,
42-
@JsonProperty("registered_country") @MaxMindDbParameter(name="registered_country") Country registeredCountry,
43-
@JsonProperty("represented_country") @MaxMindDbParameter(name="represented_country") RepresentedCountry representedCountry,
44-
@JsonProperty("subdivisions") @MaxMindDbParameter(name="subdivisions") ArrayList<Subdivision> subdivisions,
45-
@JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name="traits") Traits traits
28+
@JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
29+
@JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
30+
@JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
31+
@JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
32+
@JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
33+
@JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
34+
@JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country")
35+
Country registeredCountry,
36+
@JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country")
37+
RepresentedCountry representedCountry,
38+
@JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions")
39+
ArrayList<Subdivision> subdivisions,
40+
@JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits")
41+
Traits traits
4642
) {
4743
super(city, continent, country, location, maxmind, postal, registeredCountry,
48-
representedCountry, subdivisions, traits);
44+
representedCountry, subdivisions, traits);
4945
}
5046

5147
public CityResponse(
52-
CityResponse response,
53-
String ipAddress,
54-
Network network,
55-
List<String> locales
48+
CityResponse response,
49+
String ipAddress,
50+
Network network,
51+
List<String> locales
5652
) {
5753
super(response, ipAddress, network, locales);
5854
}

src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.maxmind.geoip2.model;
22

33
import com.fasterxml.jackson.annotation.JacksonInject;
4+
import com.fasterxml.jackson.annotation.JsonCreator;
45
import com.fasterxml.jackson.annotation.JsonProperty;
56
import com.fasterxml.jackson.annotation.JsonValue;
67
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@@ -20,8 +21,11 @@ public class ConnectionTypeResponse extends AbstractResponse {
2021
* The enumerated values that connection-type may take.
2122
*/
2223
public enum ConnectionType {
23-
DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
24-
"Cellular");
24+
DIALUP("Dialup"),
25+
CABLE_DSL("Cable/DSL"),
26+
CORPORATE("Corporate"),
27+
CELLULAR("Cellular"),
28+
SATELLITE("Satellite");
2529

2630
private final String name;
2731

@@ -40,6 +44,7 @@ public String toString() {
4044
return this.name;
4145
}
4246

47+
@JsonCreator
4348
public static ConnectionType fromString(String s) {
4449
if (s == null) {
4550
return null;
@@ -54,6 +59,8 @@ public static ConnectionType fromString(String s) {
5459
return ConnectionType.CORPORATE;
5560
case "Cellular":
5661
return ConnectionType.CELLULAR;
62+
case "Satellite":
63+
return ConnectionType.SATELLITE;
5764
default:
5865
return null;
5966
}
@@ -81,9 +88,10 @@ public ConnectionTypeResponse(
8188
}
8289

8390
public ConnectionTypeResponse(
84-
@JsonProperty("connection_type") ConnectionType connectionType,
85-
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
86-
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) Network network
91+
@JsonProperty("connection_type") ConnectionType connectionType,
92+
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
93+
@JacksonInject("network") @JsonProperty("network")
94+
@JsonDeserialize(using = NetworkDeserializer.class) Network network
8795
) {
8896
this.connectionType = connectionType;
8997
this.ipAddress = ipAddress;
@@ -92,9 +100,9 @@ public ConnectionTypeResponse(
92100

93101
@MaxMindDbConstructor
94102
public ConnectionTypeResponse(
95-
@MaxMindDbParameter(name="connection_type") String connectionType,
96-
@MaxMindDbParameter(name="ip_address") String ipAddress,
97-
@MaxMindDbParameter(name="network") Network network
103+
@MaxMindDbParameter(name = "connection_type") String connectionType,
104+
@MaxMindDbParameter(name = "ip_address") String ipAddress,
105+
@MaxMindDbParameter(name = "network") Network network
98106
) {
99107
this(
100108
ConnectionType.fromString(connectionType),
@@ -104,9 +112,9 @@ public ConnectionTypeResponse(
104112
}
105113

106114
public ConnectionTypeResponse(
107-
ConnectionTypeResponse response,
108-
String ipAddress,
109-
Network network
115+
ConnectionTypeResponse response,
116+
String ipAddress,
117+
Network network
110118
) {
111119
this(
112120
response.getConnectionType(),
@@ -133,7 +141,7 @@ public String getIpAddress() {
133141

134142
/**
135143
* @return The network associated with the record. In particular, this is
136-
* the largest network where all of the fields besides IP address have the
144+
* the largest network where all the fields besides IP address have the
137145
* same value.
138146
*/
139147
@JsonProperty

src/main/java/com/maxmind/geoip2/model/CountryResponse.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import java.util.List;
1212

1313
/**
14-
* This class provides a model for the data returned by the GeoIP2 Precision:
15-
* Country end point.
14+
* This class provides a model for the data returned by the Country web service
15+
* and the Country database.
1616
*
1717
* @see <a href="https://dev.maxmind.com/geoip/docs/web-services?lang=en">GeoIP2 Web
1818
* Services</a>
@@ -25,21 +25,24 @@ public final class CountryResponse extends AbstractCountryResponse {
2525

2626
@MaxMindDbConstructor
2727
public CountryResponse(
28-
@JsonProperty("continent") @MaxMindDbParameter(name="continent") Continent continent,
29-
@JsonProperty("country") @MaxMindDbParameter(name="country") Country country,
30-
@JsonProperty("maxmind") @MaxMindDbParameter(name="maxmind") MaxMind maxmind,
31-
@JsonProperty("registered_country") @MaxMindDbParameter(name="registered_country") Country registeredCountry,
32-
@JsonProperty("represented_country") @MaxMindDbParameter(name="represented_country") RepresentedCountry representedCountry,
33-
@JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name="traits") Traits traits
28+
@JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
29+
@JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
30+
@JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
31+
@JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country")
32+
Country registeredCountry,
33+
@JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country")
34+
RepresentedCountry representedCountry,
35+
@JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits")
36+
Traits traits
3437
) {
3538
super(continent, country, maxmind, registeredCountry, representedCountry, traits);
3639
}
3740

3841
public CountryResponse(
39-
CountryResponse response,
40-
String ipAddress,
41-
Network network,
42-
List<String> locales
42+
CountryResponse response,
43+
String ipAddress,
44+
Network network,
45+
List<String> locales
4346
) {
4447
super(response, ipAddress, network, locales);
4548
}

src/main/java/com/maxmind/geoip2/model/DomainResponse.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,28 @@ public DomainResponse(
3737

3838
@MaxMindDbConstructor
3939
public DomainResponse(
40-
@JsonProperty("domain") @MaxMindDbParameter(name="domain") String domain,
41-
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name="ip_address") String ipAddress,
42-
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) @MaxMindDbParameter(name="network") Network network
40+
@JsonProperty("domain") @MaxMindDbParameter(name = "domain") String domain,
41+
@JacksonInject("ip_address") @JsonProperty("ip_address")
42+
@MaxMindDbParameter(name = "ip_address") String ipAddress,
43+
@JacksonInject("network") @JsonProperty("network")
44+
@JsonDeserialize(using = NetworkDeserializer.class) @MaxMindDbParameter(name = "network")
45+
Network network
4346
) {
4447
this.domain = domain;
4548
this.ipAddress = ipAddress;
4649
this.network = network;
4750
}
4851

4952
public DomainResponse(
50-
DomainResponse response,
51-
String ipAddress,
52-
Network network
53+
DomainResponse response,
54+
String ipAddress,
55+
Network network
5356
) {
5457
this(response.getDomain(), ipAddress, network);
5558
}
5659

5760
/**
58-
* @return the The second level domain associated with the IP address. This
61+
* @return The second level domain associated with the IP address. This
5962
* will be something like "example.com" or "example.co.uk", not
6063
* "foo.example.com".
6164
*/
@@ -73,7 +76,7 @@ public String getIpAddress() {
7376

7477
/**
7578
* @return The network associated with the record. In particular, this is
76-
* the largest network where all of the fields besides IP address have the
79+
* the largest network where all the fields besides IP address have the
7780
* same value.
7881
*/
7982
@JsonProperty

0 commit comments

Comments
 (0)