@Test public void parseEnum_valueIsInvalid_IllegalArgumentException() { final String value = null; try { InputParser.parseEnum(value, LocationId.class, INPUT_NAME); fail(); } catch (IllegalArgumentException ex) { assertTrue(ex.getMessage().contains(INPUT_NAME)); } }
public static <T extends Enum<T>> T parseEnum(String value, Class<T> clazz, String inputName) { for (T enumm : EnumSet.allOf(clazz)) { if (enumm.toString().equals(value)) { return enumm; } } throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, inputName)); }
InputParser { public static <T extends Enum<T>> T parseEnum(String value, Class<T> clazz, String inputName) { for (T enumm : EnumSet.allOf(clazz)) { if (enumm.toString().equals(value)) { return enumm; } } throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, inputName)); } }
InputParser { public static <T extends Enum<T>> T parseEnum(String value, Class<T> clazz, String inputName) { for (T enumm : EnumSet.allOf(clazz)) { if (enumm.toString().equals(value)) { return enumm; } } throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, inputName)); } private  InputParser(); }
InputParser { public static <T extends Enum<T>> T parseEnum(String value, Class<T> clazz, String inputName) { for (T enumm : EnumSet.allOf(clazz)) { if (enumm.toString().equals(value)) { return enumm; } } throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, inputName)); } private  InputParser(); static String parseDescription(String descr); static short parseShort(String value, String inputName); static int parseInt(String value, String inputName); static boolean parseBoolean(String value, String inputName); static Region parseRegion(String value); static T parseEnum(String value, Class<T> clazz, String inputName); }
InputParser { public static <T extends Enum<T>> T parseEnum(String value, Class<T> clazz, String inputName) { for (T enumm : EnumSet.allOf(clazz)) { if (enumm.toString().equals(value)) { return enumm; } } throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, inputName)); } private  InputParser(); static String parseDescription(String descr); static short parseShort(String value, String inputName); static int parseInt(String value, String inputName); static boolean parseBoolean(String value, String inputName); static Region parseRegion(String value); static T parseEnum(String value, Class<T> clazz, String inputName);  }