use of org.openstreetmap.atlas.checks.maproulette.data.ChallengePriority in project atlas-checks by osmlab.
the class ChallengeDeserializer method deserialize.
@Override
public Challenge deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {
final JsonObject challengeObject = json.getAsJsonObject();
ChallengeDifficulty difficulty;
try {
difficulty = ChallengeDifficulty.valueOf(this.getStringValue(challengeObject, KEY_DIFFICULTY, ""));
} catch (final IllegalArgumentException e) {
logger.trace("Failed to read difficulty value from Challenge JSON, defaulting to EASY");
difficulty = ChallengeDifficulty.EASY;
}
ChallengePriority priority;
try {
priority = ChallengePriority.valueOf(this.getStringValue(challengeObject, Challenge.KEY_DEFAULT_PRIORITY, ""));
} catch (final IllegalArgumentException e) {
logger.trace("Failed to read priority value from Challenge JSON, defaulting to NONE");
priority = ChallengePriority.NONE;
}
return new Challenge(this.getStringValue(challengeObject, Challenge.KEY_NAME, ""), this.getStringValue(challengeObject, KEY_DESCRIPTION, ""), this.getStringValue(challengeObject, KEY_BLURB, ""), this.getStringValue(challengeObject, KEY_INSTRUCTION, ""), difficulty, priority, this.getValue(challengeObject, Challenge.KEY_HIGH_PRIORITY, null), this.getValue(challengeObject, Challenge.KEY_MEDIUM_PRIORITY, null), this.getValue(challengeObject, Challenge.KEY_LOW_PRIORITY, null), this.getStringValue(challengeObject, Challenge.KEY_TAGS, ""));
}
Aggregations