Class StringCollectionUtil
java.lang.Object
ch.tocco.nice2.toolbox.api.string.StringCollectionUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcutOnMaxSizeAndJoinStrings(Collection<String> collectionToJoin, String moreThanMaxElementsMessage) joins all elements of the collection using a line break.static <T> StringcutOnMaxSizeAndJoinStrings(Collection<T> collectionToJoin, Function<T, String> transformerFunction, String moreThanMaxElementsMessage) behaves the same way ascutOnMaxSizeAndJoinStrings(Collection, String)except that it accepts any type ofCollectionwhich will be transformed to a stringCollectionusing the giventransformerFunction.static StringjoinOnLineBreaks(Iterable<String> strings) static StringjoinOnLineBreaks(String... strings)
-
Method Details
-
cutOnMaxSizeAndJoinStrings
public static String cutOnMaxSizeAndJoinStrings(Collection<String> collectionToJoin, String moreThanMaxElementsMessage) joins all elements of the collection using a line break. if there are more elements incollectionToJointhan defined inmaxSize, the list will be shortened to a size ofMAX_SIZEand the message inmoreThanMaxElementsMessagewill be appended at the end. Note: use the placeholder %s inmoreThanMaxElementsMessageif you want to include the number of skipped records in the message- Parameters:
collectionToJoin- the strings to joinmoreThanMaxElementsMessage- the message to append when the collection is bigger thanmaxSize
-
cutOnMaxSizeAndJoinStrings
public static <T> String cutOnMaxSizeAndJoinStrings(Collection<T> collectionToJoin, Function<T, String> transformerFunction, String moreThanMaxElementsMessage) behaves the same way ascutOnMaxSizeAndJoinStrings(Collection, String)except that it accepts any type ofCollectionwhich will be transformed to a stringCollectionusing the giventransformerFunction. Using this method probably results in a better performance than transforming theCollectionyourself because it will be shortened, if necessary, before the transformation- Parameters:
collectionToJoin- the strings to jointransformerFunction- a function which must return aStringmoreThanMaxElementsMessage- the message to append when the collection is bigger thanmaxSize
-
joinOnLineBreaks
-
joinOnLineBreaks
-