Class SimpleMaskChar

java.lang.Object
atlantafx.base.util.SimpleMaskChar
All Implemented Interfaces:
MaskChar

public final class SimpleMaskChar extends Object implements MaskChar
The default MaskChar implementation that should be suitable for anything except heavily custom logic.
  • Constructor Details

    • SimpleMaskChar

      public SimpleMaskChar(Predicate<Character> matchExpr)
      Creates a SimpleMaskChar.
      Parameters:
      matchExpr - The matching predicate that determines which characters are masked.
      See Also:
    • SimpleMaskChar

      public SimpleMaskChar(Predicate<Character> matchExpr, UnaryOperator<Character> transform)
      Creates a SimpleMaskChar.
      Parameters:
      matchExpr - The matching predicate that determines which characters are masked.
      transform - The transformation function that is applied to input characters.
      See Also:
    • SimpleMaskChar

      public SimpleMaskChar(Predicate<Character> matchExpr, UnaryOperator<Character> transform, char placeholder)
      Creates a SimpleMaskChar.
      Parameters:
      matchExpr - The matching predicate that determines which characters are masked.
      transform - The transformation function that is applied to input characters.
      placeholder - The placeholder character to use for masking.
      See Also:
    • SimpleMaskChar

      public SimpleMaskChar(Predicate<Character> matchExpr, UnaryOperator<Character> transform, char placeholder, boolean fixed)
      Creates a SimpleMaskChar.
      Parameters:
      matchExpr - The matching predicate that determines which characters are masked.
      transform - The transformation function that is applied to input characters. No transformation is applied by default.
      placeholder - The placeholder character to use for masking. The default replacement is underscore character.
      fixed - Boolean value indicating if the character is fixed or not. Default is false.
  • Method Details

    • isAllowed

      public boolean isAllowed(char ch)
      Returns "true" if the character is allowed, "false" otherwise.
      Specified by:
      isAllowed in interface MaskChar
    • transform

      public char transform(char ch)
      Transforms user input character before setting.
      Specified by:
      transform in interface MaskChar
    • getPlaceholder

      public char getPlaceholder()
      Returns the placeholder for the mask character.
      Specified by:
      getPlaceholder in interface MaskChar
    • isFixed

      public boolean isFixed()
      Returns whether character is fixed (prefix, suffix or separator).
      Specified by:
      isFixed in interface MaskChar
    • fixed

      public static SimpleMaskChar fixed(char ch)
      A utility method for creating a fixed character - that is, the character used to represent the fixed part (a prefix or a suffix) of the input mask.