44import com .maxmind .geoip2 .model .InsightsResponse ;
55import com .maxmind .geoip2 .record .*;
66
7+ import java .util .ArrayList ;
8+ import java .util .Collections ;
79import java .util .List ;
810
911/**
@@ -13,6 +15,7 @@ public final class IpAddress extends InsightsResponse implements IpAddressInterf
1315 private final GeoIp2Country country ;
1416 private final GeoIp2Location location ;
1517 private final Double risk ;
18+ private final List <IpRiskReason > riskReasons ;
1619
1720 public IpAddress (
1821 @ JsonProperty ("city" ) City city ,
@@ -24,13 +27,36 @@ public IpAddress(
2427 @ JsonProperty ("registered_country" ) Country registeredCountry ,
2528 @ JsonProperty ("represented_country" ) RepresentedCountry representedCountry ,
2629 @ JsonProperty ("risk" ) Double risk ,
30+ @ JsonProperty ("risk_reasons" ) List <IpRiskReason > riskReasons ,
2731 @ JsonProperty ("subdivisions" ) List <Subdivision > subdivisions ,
2832 @ JsonProperty ("traits" ) Traits traits
2933 ) {
3034 super (city , continent , country , location , maxmind , postal , registeredCountry , representedCountry , subdivisions , traits );
3135 this .country = country == null ? new GeoIp2Country () : country ;
3236 this .location = location == null ? new GeoIp2Location () : location ;
3337 this .risk = risk ;
38+ this .riskReasons = Collections .unmodifiableList (riskReasons == null ? new ArrayList <>() : riskReasons );
39+ }
40+
41+ /**
42+ * @deprecated This constructor only exists for backward compatibility
43+ * and will be removed in the next major release.
44+ */
45+ public IpAddress (
46+ City city ,
47+ Continent continent ,
48+ GeoIp2Country country ,
49+ GeoIp2Location location ,
50+ MaxMind maxmind ,
51+ Postal postal ,
52+ Country registeredCountry ,
53+ RepresentedCountry representedCountry ,
54+ Double risk ,
55+ List <Subdivision > subdivisions ,
56+ Traits traits
57+ ) {
58+ this (city , continent , country , location , maxmind , postal , registeredCountry , representedCountry ,
59+ risk , null , subdivisions , traits );
3460 }
3561
3662 public IpAddress () {
@@ -63,4 +89,14 @@ public GeoIp2Location getLocation() {
6389 public Double getRisk () {
6490 return risk ;
6591 }
92+
93+ /**
94+ * @return An unmodifiable list contains risk reason objects identifying
95+ * the reasons why the IP address received the associated risk. This will
96+ * be an empty list if there are no reasons.
97+ */
98+ @ JsonProperty ("risk_reasons" )
99+ public final List <IpRiskReason > getRiskReasons () {
100+ return riskReasons ;
101+ }
66102}
0 commit comments