Class ConditionalMapper.Builder

  • Enclosing class:
    ConditionalMapper

    public static class ConditionalMapper.Builder
    extends Object
    Creates a new mapper builder.
    • Constructor Detail

      • Builder

        public Builder()
        Creates a builder with no specified trigger character. Unless a trigger is specified using trigger(char) or trigger(int), the mapper will always be active.
    • Method Detail

      • trigger

        public ConditionalMapper.Builder trigger​(char trigger)
        Sets a trigger that activates the character mapper.
        Parameters:
        trigger - the trigger
        Returns:
        returns this builder
      • trigger

        public ConditionalMapper.Builder trigger​(int trigger)
        Sets a trigger that activates the character mapper.
        Parameters:
        trigger - the trigger
        Returns:
        returns this builder
      • map

        public ConditionalMapper.Builder map​(String replace,
                                             String with)

        Defines that characters found in the replace string are to be replaced by the character at the corresponding position in the with string.

        If there is a character in the replace string with no character at a corresponding position in the with string (because replace is longer than with), then that character will be replaced by an empty string.

        If a character occurs more than once in the replace string, then the last occurrence determines the replacement character.

        If the with string is longer than the second argument string, then excess characters are ignored.

        Calling map("abc", "ABC") is equal to calling:

         put('a', "A");
         put('b', "B");
         put('c', "C");
         

        Note however that put(int, String) and put(char, String) also allow a replacement that contains more than one character, which map(String, String) does not.

        Parameters:
        replace - a list of characters to replace
        with - a list of replacement characters
        Returns:
        returns this builder
      • put

        public ConditionalMapper.Builder put​(char key,
                                             String value)
        Defines a replacement string for the specified character.
        Parameters:
        key - the character
        value - the replacement
        Returns:
        returns this builder
      • put

        public ConditionalMapper.Builder put​(int key,
                                             String value)
        Defines a replacement string for the specified Unicode code point.
        Parameters:
        key - the code point
        value - the replacement
        Returns:
        returns this builder
      • putIgnorable

        public ConditionalMapper.Builder putIgnorable​(char value)
        Adds a transparent mapping for the specified character. In other words, this character will not be replaced, but will not cause the mapper to deactivate either.
        Parameters:
        value - the character
        Returns:
        returns this builder
      • putIgnorable

        public ConditionalMapper.Builder putIgnorable​(int value)
        Adds a transparent mapping for the specified Unicode code point. In other words, this code point will not be replaced, but will not cause the mapper to deactivate either.
        Parameters:
        value - the character
        Returns:
        returns this builder
      • build

        public ConditionalMapper build()
        Builds the mapper with the current configuration.
        Returns:
        returns a new mapper instance