Class Strings


  • @API(status=EXPERIMENTAL,
         since="1.3.0")
    public final class Strings
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Strings()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.function.Function<java.lang.String,​java.lang.String> consistentlyReplace​(java.util.regex.Pattern pattern, java.util.function.BiFunction<java.lang.Integer,​java.lang.String,​java.lang.String> generator)
      Creates a function that, when applied to a string, will replace all matches of the given pattern with a value returned by the given generator function.
      static java.util.function.Function<java.lang.String,​java.lang.String> consistentlyReplace​(java.util.regex.Pattern pattern, java.util.function.Function<java.lang.Integer,​java.lang.String> generator)
      Creates a function that, when applied to a string, will replace all matches of the given pattern with a value returned by the given generator function.
      • Methods inherited from class java.lang.Object

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

      • Strings

        public Strings()
    • Method Detail

      • consistentlyReplace

        public static java.util.function.Function<java.lang.String,​java.lang.String> consistentlyReplace​(java.util.regex.Pattern pattern,
                                                                                                               java.util.function.BiFunction<java.lang.Integer,​java.lang.String,​java.lang.String> generator)
        Creates a function that, when applied to a string, will replace all matches of the given pattern with a value returned by the given generator function. Additionally, when the same string is matched a again by the pattern, it will be replaced with the same generated string as the first.
        Parameters:
        pattern - The pattern to find.
        generator - A generator that is used to create replacements for matched strings. The first parameter passed to the function is the count of different strings matched so far. The second parameter is the actually matched String.
        Returns:
        A function that will execute above explained replacements to a string to which it is applied
        See Also:
        Generators
      • consistentlyReplace

        public static java.util.function.Function<java.lang.String,​java.lang.String> consistentlyReplace​(java.util.regex.Pattern pattern,
                                                                                                               java.util.function.Function<java.lang.Integer,​java.lang.String> generator)
        Creates a function that, when applied to a string, will replace all matches of the given pattern with a value returned by the given generator function. Additionally, when the same string is matched a again by the pattern, it will be replaced with the same generated string as the first.
        Parameters:
        pattern - The pattern to find.
        generator - A generator that is used to create replacements for matched strings. The parameter passed to the function is the count of different strings matched so far.
        Returns:
        A function that will execute above explained replacements to a string to which it is applied
        See Also:
        Generators, consistentlyReplace(Pattern, BiFunction)