Class Splitter

  • All Implemented Interfaces:

    
    public class Splitter
    
                        
    Since:

    2023-06-13

    Author:

    trydofor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Splitter()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static List<String> list(@NotNull() String sep, String str) split string by separator
      static List<String> list(@NotNull() String sep, String str, int max) split string by separator
      static <T> List<T> list(@NotNull() String sep, String str, @NotNull() Function<String, T> fun) split string by separator and convert to T
      static <T> List<T> list(@NotNull() String sep, String str, int max, @NotNull() Function<String, T> fun) split string by separator and convert to T
      static int count(@NotNull() String sep, String str) count items split by separator
      0 - if str is empty
      1 - if str does not contain sep
      n+1 - if str contains n sep
      
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Splitter

        Splitter()
    • Method Detail

      • list

        @NotNull() static List<String> list(@NotNull() String sep, String str)

        split string by separator

        Parameters:
        sep - separator
        str - string
        Returns:

        list of string

      • list

        @NotNull() static List<String> list(@NotNull() String sep, String str, int max)

        split string by separator

        Parameters:
        sep - separator
        str - string
        max - max items
        Returns:

        list of string

      • list

        @NotNull() static <T> List<T> list(@NotNull() String sep, String str, @NotNull() Function<String, T> fun)

        split string by separator and convert to T

        Parameters:
        sep - separator
        str - string
        fun - convert string to T
        Returns:

        list of T

      • list

        @NotNull() static <T> List<T> list(@NotNull() String sep, String str, int max, @NotNull() Function<String, T> fun)

        split string by separator and convert to T

        Parameters:
        sep - separator
        str - string
        max - max items
        fun - convert string to T
        Returns:

        list of T

      • count

         static int count(@NotNull() String sep, String str)

        count items split by separator

        0 - if str is empty
        1 - if str does not contain sep
        n+1 - if str contains n sep
        
        Parameters:
        sep - separator
        str - string
        Returns:

        count of items