com.maxmind.geoip2.record.Continent 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;
/**
*
* Contains data for the continent record associated with an IP address.
*
*
* This record is returned by all the end points.
*
*
* Do not use any of the continent names as a database or map key. Use the
* value returned by {@link #getGeoNameId} or {@link #getCode} instead.
*
*/
public final class Continent extends AbstractNamedRecord {
private final String code;
public Continent() {
this(null, null, (Integer) null, null);
}
public Continent(
@JacksonInject("locales") List locales,
@JsonProperty("code") String code,
@JsonProperty("geoname_id") Integer geoNameId,
@JsonProperty("names") Map names
) {
super(locales, geoNameId, names);
this.code = code;
}
@MaxMindDbConstructor
public Continent(
@MaxMindDbParameter(name="locales") List locales,
@MaxMindDbParameter(name="code") String code,
@MaxMindDbParameter(name="geoname_id") Long geoNameId,
@MaxMindDbParameter(name="names") Map names
) {
this(
locales,
code,
geoNameId != null ? geoNameId.intValue() : null,
names
);
}
public Continent(
Continent continent,
List locales
) {
this(
locales,
continent.getCode(),
continent.getGeoNameId(),
continent.getNames()
);
}
/**
* @return A two character continent code like "NA" (North America) or "OC"
* (Oceania). This attribute is returned by all end points.
*/
public String getCode() {
return this.code;
}
}