/** * Value is split by comma and trimmed. Never returns null. * <br> * Examples : * <ul> * <li>"one,two,three " -> ["one", "two", "three"]</li> * <li>" one, two, three " -> ["one", "two", "three"]</li> * <li>"one, , three" -> ["one", "", "three"]</li> * </ul> */ public String[] getStringArray(String key) { String effectiveKey = definitions.validKey(key); Optional<PropertyDefinition> def = getDefinition(effectiveKey); if ((def.isPresent()) && (def.get().multiValues())) { String value = getString(key); if (value == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } List<String> values = new ArrayList<>(); for (String v : Splitter.on(",").trimResults().split(value)) { values.add(v.replace("%2C", ",")); } return values.toArray(new String[values.size()]); } return getStringArrayBySeparator(key, ","); }
/** * Value is split by comma and trimmed. Never returns null. * <p/> * Examples : * <ul> * <li>"one,two,three " -> ["one", "two", "three"]</li> * <li>" one, two, three " -> ["one", "two", "three"]</li> * <li>"one, , three" -> ["one", "", "three"]</li> * </ul> */ public String[] getStringArray(String key) { PropertyDefinition property = getDefinitions().get(key); if ((null != property) && (property.multiValues())) { String value = getString(key); if (value == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } List<String> values = Lists.newArrayList(); for (String v : Splitter.on(",").trimResults().split(value)) { values.add(v.replace("%2C", ",")); } return values.toArray(new String[values.size()]); } return getStringArrayBySeparator(key, ","); }
/** * Value is split by comma and trimmed. Never returns null. * <br> * Examples : * <ul> * <li>"one,two,three " -> ["one", "two", "three"]</li> * <li>" one, two, three " -> ["one", "two", "three"]</li> * <li>"one, , three" -> ["one", "", "three"]</li> * </ul> */ public String[] getStringArray(String key) { String effectiveKey = definitions.validKey(key); Optional<PropertyDefinition> def = getDefinition(effectiveKey); if ((def.isPresent()) && (def.get().multiValues())) { String value = getString(key); if (value == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } List<String> values = new ArrayList<>(); for (String v : Splitter.on(",").trimResults().split(value)) { values.add(v.replace("%2C", ",")); } return values.toArray(new String[values.size()]); } return getStringArrayBySeparator(key, ","); }