Class CasedString.StringCase

java.lang.Object
org.apache.rat.utils.CasedString.StringCase
Enclosing class:
CasedString

public static final class CasedString.StringCase extends Object
The definition of a String case.
Since:
0.17
  • Field Details

  • Constructor Details

    • StringCase

      public StringCase(String name, Predicate<Character> splitter, boolean preserveSplit, Function<String[],String> joiner)
      Constructs a StringCase
      Parameters:
      name - the name of the case.
      splitter - the splitter to determine when to split a string.
      preserveSplit - the preserveSplit flag.
      joiner - the joiner to assemble the String from the segments.
    • StringCase

      public StringCase(String name, char delimiter)
      Constructs a String case for the common cases where the delimiter is not preserved in the segments.
      Parameters:
      name - the name of the case.
      delimiter - the delimiter between segments.
    • StringCase

      public StringCase(String name, Predicate<Character> splitter, boolean preserveSplit, Function<String[],String> joiner, UnaryOperator<String> postProcess)
      Constructs a StingCase.
      Parameters:
      name - the name of the string case.
      splitter - the splitter to detect segments.
      preserveSplit - the flag to preserve the splitter character.
      joiner - the joiner to assemble a String from segments.
      postProcess - the post-process applied to the segments after the splitter has created them.
  • Method Details

    • simpleJoiner

      public static Function<String[],String> simpleJoiner(char delimiter)
      A simple joiner that assembles a String from a collection of segments. Correctly handles the case where there are zero length segments.
      Parameters:
      delimiter - the delimiter to use between the segments.
      Returns:
      the assembled string.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • assemble

      public String assemble(String[] segments)
      Assembles segments into a String.
      Parameters:
      segments - the segments to assemble.
      Returns:
      the complete String.
    • getSegments

      public String[] getSegments(String string)
      Parses a String into segments.
      Parameters:
      string - the string to parse
      Returns:
      the segments from the string.