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,48 @@ 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+ * @param city The city information.
46+ * @param continent The continent information.
47+ * @param country The country information.
48+ * @param location The location information.
49+ * @param maxmind MaxMind-specific information.
50+ * @param postal The postal information.
51+ * @param registeredCountry The information about the country where the IP was registered.
52+ * @param representedCountry The represented country, e.g., for military bases in other countries.
53+ * @param risk The IP risk.
54+ * @param subdivisions The list of subdivisions.
55+ * @param traits Information about various other IP traits.
56+ */
57+ public IpAddress (
58+ City city ,
59+ Continent continent ,
60+ GeoIp2Country country ,
61+ GeoIp2Location location ,
62+ MaxMind maxmind ,
63+ Postal postal ,
64+ Country registeredCountry ,
65+ RepresentedCountry representedCountry ,
66+ Double risk ,
67+ List <Subdivision > subdivisions ,
68+ Traits traits
69+ ) {
70+ this (city , continent , country , location , maxmind , postal , registeredCountry , representedCountry ,
71+ risk , null , subdivisions , traits );
3472 }
3573
3674 public IpAddress () {
@@ -63,4 +101,14 @@ public GeoIp2Location getLocation() {
63101 public Double getRisk () {
64102 return risk ;
65103 }
104+
105+ /**
106+ * @return An unmodifiable list containing risk reason objects that identify
107+ * the reasons why the IP address received the associated risk. This will
108+ * be an empty list if there are no reasons.
109+ */
110+ @ JsonProperty ("risk_reasons" )
111+ public final List <IpRiskReason > getRiskReasons () {
112+ return riskReasons ;
113+ }
66114}
0 commit comments