Class StringCollectionUtil

java.lang.Object
ch.tocco.nice2.toolbox.api.string.StringCollectionUtil

public class StringCollectionUtil extends Object
  • 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 in collectionToJoin than defined in maxSize, the list will be shortened to a size of MAX_SIZE and the message in moreThanMaxElementsMessage will be appended at the end. Note: use the placeholder %s in moreThanMaxElementsMessage if you want to include the number of skipped records in the message
      Parameters:
      collectionToJoin - the strings to join
      moreThanMaxElementsMessage - the message to append when the collection is bigger than maxSize
    • cutOnMaxSizeAndJoinStrings

      public static <T> String cutOnMaxSizeAndJoinStrings(Collection<T> collectionToJoin, Function<T,String> transformerFunction, String moreThanMaxElementsMessage)
      behaves the same way as cutOnMaxSizeAndJoinStrings(Collection, String) except that it accepts any type of Collection which will be transformed to a string Collection using the given transformerFunction . Using this method probably results in a better performance than transforming the Collection yourself because it will be shortened, if necessary, before the transformation
      Parameters:
      collectionToJoin - the strings to join
      transformerFunction - a function which must return a String
      moreThanMaxElementsMessage - the message to append when the collection is bigger than maxSize
    • joinOnLineBreaks

      public static String joinOnLineBreaks(String... strings)
    • joinOnLineBreaks

      public static String joinOnLineBreaks(Iterable<String> strings)