@Test public void testParseValue() throws GuacamoleException { assertEquals(Fish.SALMON, FAVORITE_FISH.parseValue("salmon")); assertEquals(Fish.TROUT, FAVORITE_FISH.parseValue("trout")); assertEquals(Fish.MACKEREL, FAVORITE_FISH.parseValue("mackerel")); assertEquals(Fish.TUNA, FAVORITE_FISH.parseValue("tuna")); assertEquals(Fish.SARDINE, FAVORITE_FISH.parseValue("sardine")); }
@Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } EnumGuacamoleProperty(Map<String, T> valueMapping);  EnumGuacamoleProperty(Class<T> enumClass);  EnumGuacamoleProperty(String key, T value, Object... additional); }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } EnumGuacamoleProperty(Map<String, T> valueMapping);  EnumGuacamoleProperty(Class<T> enumClass);  EnumGuacamoleProperty(String key, T value, Object... additional); @Override T parseValue(String value); }
EnumGuacamoleProperty implements GuacamoleProperty<T> { @Override public T parseValue(String value) throws GuacamoleException { if (value == null) return null; T parsedValue = valueMapping.get(value); if (parsedValue != null) return parsedValue; List<String> legalValues = new ArrayList<>(valueMapping.keySet()); Collections.sort(legalValues); throw new GuacamoleServerException(String.format("\"%s\" is not a " + "valid value for property \"%s\". Valid values are: \"%s\"", value, getName(), String.join("\", \"", legalValues))); } EnumGuacamoleProperty(Map<String, T> valueMapping);  EnumGuacamoleProperty(Class<T> enumClass);  EnumGuacamoleProperty(String key, T value, Object... additional); @Override T parseValue(String value);  }