Class MaskedPasswordBuilder


  • public class MaskedPasswordBuilder
    extends Object
    A string visitor that builds the same string, but then with masked passwords.
    Since:
    2.0.0
    Author:
    Rutger Lubbers
    • Constructor Detail

      • MaskedPasswordBuilder

        public MaskedPasswordBuilder​(String stringToMask,
                                     String pattern)
        The constructor.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Returns true if the string to mask has more characters.
      • next

        public void next()
        Advances the cursor to the next character.
      • currentCharIsOneOf

        public boolean currentCharIsOneOf​(Character... choices)
        Returns true of the current character is one of the choices.
      • currentCharIs

        public boolean currentCharIs​(Character character)
        Returns true if the current character is character.
      • currentCharIsWhitespace

        public boolean currentCharIsWhitespace()
        Returns true if the current character is a whitespace.
      • mark

        public void mark()
        Saves the current index, to be used by reset().
      • reset

        public void reset()
        Resets the current character (or index) to the one set by mark().
      • maskPasswordAt

        public void maskPasswordAt​(Integer index)
        Appends the password mask at the index.
      • getCurrentIndex

        public int getCurrentIndex()
        Returns the current index.
      • findNextPassword

        public boolean findNextPassword()
        Returns true if there is another password to be found in the string to mask.
      • build

        public String build()
        Builds the masked string.