@Test void mapToStrings() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put("string", "bar"); properties.put("integer", 100); properties.put("boolean", false); properties.put("collection", asList("foo", "bar")); Map<String, String> result = ValidatorFactory.toStrings(properties); assertEquals("bar", result.get("string")); assertEquals("100", result.get("integer")); assertEquals("false", result.get("boolean")); assertEquals("foo,bar", result.get("collection")); }
@SuppressWarnings("unchecked") static Map<String, String> toStrings(Map<String, Object> properties) { Map<String, String> result = new LinkedHashMap<>(); for (Map.Entry<String, Object> e : properties.entrySet()) { if (e.getValue() instanceof Iterable) result.put(e.getKey(), join((Iterable)e.getValue(), ',')); else result.put(e.getKey(), e.getValue().toString()); } return result; }
ValidatorFactory { @SuppressWarnings("unchecked") static Map<String, String> toStrings(Map<String, Object> properties) { Map<String, String> result = new LinkedHashMap<>(); for (Map.Entry<String, Object> e : properties.entrySet()) { if (e.getValue() instanceof Iterable) result.put(e.getKey(), join((Iterable)e.getValue(), ',')); else result.put(e.getKey(), e.getValue().toString()); } return result; } }
ValidatorFactory { @SuppressWarnings("unchecked") static Map<String, String> toStrings(Map<String, Object> properties) { Map<String, String> result = new LinkedHashMap<>(); for (Map.Entry<String, Object> e : properties.entrySet()) { if (e.getValue() instanceof Iterable) result.put(e.getKey(), join((Iterable)e.getValue(), ',')); else result.put(e.getKey(), e.getValue().toString()); } return result; }  }
ValidatorFactory { @SuppressWarnings("unchecked") static Map<String, String> toStrings(Map<String, Object> properties) { Map<String, String> result = new LinkedHashMap<>(); for (Map.Entry<String, Object> e : properties.entrySet()) { if (e.getValue() instanceof Iterable) result.put(e.getKey(), join((Iterable)e.getValue(), ',')); else result.put(e.getKey(), e.getValue().toString()); } return result; }  static List<ValidatorConfiguration> getConfigurations(String lang); static Validator getInstance(String validatorName); static Validator getInstance(ValidatorConfiguration config, Configuration globalConfig); }
ValidatorFactory { @SuppressWarnings("unchecked") static Map<String, String> toStrings(Map<String, Object> properties) { Map<String, String> result = new LinkedHashMap<>(); for (Map.Entry<String, Object> e : properties.entrySet()) { if (e.getValue() instanceof Iterable) result.put(e.getKey(), join((Iterable)e.getValue(), ',')); else result.put(e.getKey(), e.getValue().toString()); } return result; }  static List<ValidatorConfiguration> getConfigurations(String lang); static Validator getInstance(String validatorName); static Validator getInstance(ValidatorConfiguration config, Configuration globalConfig);  }