com.maxmind.geoip2.record.City Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geoip2 Show documentation
Show all versions of geoip2 Show documentation
GeoIP2 webservice client and database reader
package com.maxmind.geoip2.record;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import java.util.List;
import java.util.Map;
/**
*
* City-level data associated with an IP address.
*
*
* This record is returned by all the end points except the Country end point.
*
*
* Do not use any of the city names as a database or map key. Use the value
* returned by {@link #getGeoNameId} instead.
*
*/
public final class City extends AbstractNamedRecord {
private final Integer confidence;
public City() {
this(null, null, null, null);
}
@MaxMindDbConstructor
public City(
@JacksonInject("locales") @MaxMindDbParameter(name = "locales") List locales,
@JsonProperty("confidence") @MaxMindDbParameter(name = "confidence") Integer confidence,
@JsonProperty("geoname_id") @MaxMindDbParameter(name = "geoname_id") Long geoNameId,
@JsonProperty("names") @MaxMindDbParameter(name = "names") Map names
) {
super(locales, geoNameId, names);
this.confidence = confidence;
}
public City(
City city,
List locales
) {
this(
locales,
city.getConfidence(),
city.getGeoNameId(),
city.getNames()
);
}
/**
* @return A value from 0-100 indicating MaxMind's confidence that the city
* is correct. This attribute is only available from the Insights
* end point and the GeoIP2 Enterprise database.
*/
public Integer getConfidence() {
return this.confidence;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy