Add more MaxMind results

This commit is contained in:
Colin McDonald 2016-06-24 02:58:44 -04:00
parent 3de5e8d756
commit 6eeb153413
4 changed files with 10 additions and 8 deletions

View File

@ -16,12 +16,12 @@ public final class MaxMindLocation {
public MaxMindLocation() {} // For Jackson
public MaxMindLocation(JsonObject legacy) {
this.latitude = legacy.getDouble("latitude");
this.longitude = legacy.getDouble("longitude");
this.accuracyRadius = legacy.getInteger("accuracy_radius");
this.timeZone = legacy.getString("time_zone");
this.latitude = legacy.getDouble("latitude", -1D);
this.longitude = legacy.getDouble("longitude", -1D);
this.accuracyRadius = legacy.getInteger("accuracy_radius", -1);
this.timeZone = legacy.getString("time_zone", "");
this.populationDensity = legacy.getInteger("population_density", -1);
this.metroCode = legacy.getInteger("metro_code", -1); // Metro codes are US only
this.metroCode = legacy.getInteger("metro_code", -1);
this.averageIncome = legacy.getInteger("average_income", -1);
}

View File

@ -1,6 +1,7 @@
package net.frozenorb.apiv3.maxmind;
import com.google.common.collect.ImmutableList;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import lombok.Getter;
@ -31,7 +32,7 @@ public final class MaxMindResult {
List<MaxMindSubdivision> subdivisions = new LinkedList<>();
for (Object subdivision : legacy.getJsonArray("subdivisions")) {
for (Object subdivision : legacy.getJsonArray("subdivisions", new JsonArray())) {
subdivisions.add(new MaxMindSubdivision((JsonObject) subdivision));
}

View File

@ -19,7 +19,7 @@ public final class MaxMindTraits {
this.domain = legacy.getString("domain", "");
this.asn = legacy.getInteger("autonomous_system_number", -1);
this.asnOrganization = legacy.getString("autonomous_system_organization" , "");
this.userType = MaxMindUserType.valueOf(legacy.getString("user_type", "").toUpperCase());
this.userType = legacy.containsKey("user_type") ? MaxMindUserType.valueOf(legacy.getString("user_type").toUpperCase()) : MaxMindUserType.UNKNOWN;
this.organization = legacy.getString("organization", "");
}

View File

@ -18,7 +18,8 @@ public enum MaxMindUserType {
ROUTER(true),
SCHOOL(true),
SEARCH_ENGINE_SPIDER(false),
TRAVELER(true);
TRAVELER(true),
UNKNOWN(true);
@Getter private boolean allowed;