public static FlagType getFlagTypeFromName(String name) { try { return FlagType.valueOf(name.toUpperCase()); } catch (IllegalArgumentException e) { throw new MyTownCommandException("mytown.cmd.err.flagNotExists", e, name); } }
@Override public Flag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); FlagType flagType = FlagType.valueOf(jsonObject.get("flagType").getAsString()); return new Flag(flagType, jsonObject.get("value").getAsString()); }
public static Flag getFlagFromName(Flag.Container flagsContainer, String name) { Flag flag; try { flag = flagsContainer.get(FlagType.valueOf(name.toUpperCase())); } catch (IllegalArgumentException ex) { throw new MyTownCommandException("mytown.cmd.err.flagNotExists", ex, name); } if (flag == null) throw new MyTownCommandException("mytown.cmd.err.flagNotExists", name); return flag; }