/** * Builds a newline-delimited string from a list. * * @param list The list of strings to concatenate. * @return A string contains the list of elements separated by the newline character. */ public static String fromList(Iterable<?> list) { return fromList(list, "\n"); }
/** * Builds a delimited string from a list. * * @param list The list of strings to concatenate. * @param delimiter The delimiter to use to separate elements. * @return A string contains the list of elements separated by the specified delimiter. */ public static String fromList(Iterable<?> list, String delimiter) { return fromList(list, delimiter, ""); }
/** * Returns css gradient specifier. * * @param colors List of colors for gradient. * @return The gradient specifier. */ private String getGradValue(String... colors) { return "linear-gradient(to right," + StrUtil.fromList(Arrays.asList(colors), ", ", "none") + ")"; }
private String _formatColors(String[] colors) { return colors != null ? StrUtil.fromList(Arrays.asList(colors), ",") : null; }
@Override public void saveValues(String propertyName, String instanceName, boolean asGlobal, List<String> values) { saveValue(propertyName, instanceName, asGlobal, values == null ? null : StrUtil.fromList(values)); }
/** * Parses XML from a list of strings. * * @param xml String iterable containing valid XML. * @return XML document. * @throws Exception Unspecified exception. */ public static Document parseXMLFromList(Iterable<String> xml) throws Exception { return parseXMLFromString(StrUtil.fromList(xml)); }
String str = StrUtil.fromList(strList, ","); assertEquals(original, str); str = StrUtil.fromList(intList, ","); assertEquals(original, str); str = StrUtil.fromList(intList, ","); assertEquals("1,2,,4,5", str); str = StrUtil.fromList(intList, ",", null); assertEquals("1,2,4,5", str); str = StrUtil.fromList(intList, ",", "3"); assertEquals(original, str); List<Object> iterList = new ArrayList<>();