Convert MaxMindTraits' user_type to an enum

This commit is contained in:
Colin McDonald 2016-06-21 17:06:34 -04:00
parent d261ef507a
commit 7b594d695b
2 changed files with 32 additions and 2 deletions

View File

@ -9,7 +9,7 @@ public final class MaxMindTraits {
@Getter private String domain;
@Getter private int asn;
@Getter private String asnOrganization;
@Getter private String type; // TODO: MAKE ENUM
@Getter private MaxMindUserType userType;
@Getter private String organization;
public MaxMindTraits() {} // For Jackson
@ -19,7 +19,7 @@ public final class MaxMindTraits {
this.domain = legacy.getString("domain");
this.asn = legacy.getInteger("autonomous_system_number");
this.asnOrganization = legacy.getString("autonomous_system_organization");
this.type = legacy.getString("user_type");
this.userType = MaxMindUserType.valueOf(legacy.getString("user_type").toUpperCase());
this.organization = legacy.getString("organization");
}

View File

@ -0,0 +1,30 @@
package net.frozenorb.apiv3.maxmind;
import lombok.Getter;
public enum MaxMindUserType {
BUSINESS(true),
CAFE(true),
CELLULAR(true),
COLLEGE(true),
CONTENT_DELIVERY_NETWORK(false),
DIALUP(true),
GOVERNMENT(true),
HOSTING(false),
LIBRARY(true),
MILITARY(true),
RESIDENTIAL(true),
ROUTER(true),
SCHOOL(true),
SEARCH_ENGINE_SPIDER(false),
TRAVELER(true);
// TODO: ACTUALLY CARE ABOUT THIS
@Getter private boolean allowed;
MaxMindUserType(boolean allowed) {
this.allowed = allowed;
}
}