Exemplo n.º 1
0
 public static FlagType getFlagTypeFromName(String name) {
   try {
     return FlagType.valueOf(name.toUpperCase());
   } catch (IllegalArgumentException e) {
     throw new MyTownCommandException("mytown.cmd.err.flagNotExists", e, name);
   }
 }
Exemplo n.º 2
0
 @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());
 }
Exemplo n.º 3
0
 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;
 }