Class CheckerString

java.lang.Object
util.AbstractChecker<String,CheckerString>
specialized_checkers.CheckerString
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<String,CheckerString>,String>

public class CheckerString extends AbstractChecker<String,CheckerString>
CheckerString is a specialized checker for validating and performing assertions on String values.

It provides a fluent API for common string validations such as checking for emptiness, blankness, length constraints, content, format, and more.

  • Constructor Details

    • CheckerString

      protected CheckerString(String string, String name)
      Constructs a new CheckerString with the specified string and name.
      Parameters:
      string - the String to be associated with this checker
      name - the name of the checker
  • Method Details

    • check

      public static CheckerString check(String string, String name)
      Creates a new CheckerString instance for the given string and name.
      Parameters:
      string - the string value to be checked
      name - the name to identify the string in error messages
      Returns:
      a CheckerString instance for further validations
    • check

      public static CheckerString check(String string)
      Creates a new CheckerString instance for the given string with a default name.
      Parameters:
      string - the string value to be checked
      Returns:
      a CheckerString instance for further validations
    • self

      protected CheckerString self()
      Returns this instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<String,CheckerString>
      Returns:
      this CheckerString instance
    • isEmpty

      public CheckerString isEmpty()
      Checks if the string is empty.
      Returns:
      this CheckerString instance for chaining
    • isBlank

      public CheckerString isBlank()
      Checks if the string is blank (empty or contains only whitespace).
      Returns:
      this CheckerString instance for chaining
    • min

      public CheckerString min(int min)
      Checks if the string length is greater than the specified minimum.
      Parameters:
      min - the minimum length (exclusive)
      Returns:
      this CheckerString instance for chaining
    • max

      public CheckerString max(int max)
      Checks if the string length is less than the specified maximum.
      Parameters:
      max - the maximum length (exclusive)
      Returns:
      this CheckerString instance for chaining
    • inRange

      public CheckerString inRange(int min, int max)
      Checks if the string length is within the specified range (exclusive).
      Parameters:
      min - the minimum length (exclusive)
      max - the maximum length (exclusive)
      Returns:
      this CheckerString instance for chaining
    • isEqualsIgnoreCase

      public CheckerString isEqualsIgnoreCase(String anotherString)
      Checks if the string equals another string, ignoring case considerations.
      Parameters:
      anotherString - the string to compare with, ignoring case
      Returns:
      this CheckerString instance for chaining
    • contains

      public CheckerString contains(CharSequence s)
      Checks if the string contains the specified sequence of char values.
      Parameters:
      s - the sequence to search for
      Returns:
      this CheckerString instance for chaining
    • startsWith

      public CheckerString startsWith(String prefix)
      Checks if the string starts with the specified prefix.
      Parameters:
      prefix - the prefix to look for
      Returns:
      this CheckerString instance for chaining
    • endsWith

      public CheckerString endsWith(String suffix)
      Checks if the string ends with the specified suffix.
      Parameters:
      suffix - the suffix to look for
      Returns:
      this CheckerString instance for chaining
    • matches

      public CheckerString matches(String regex)
      Checks if the string matches the given regular expression.
      Parameters:
      regex - the regular expression to match
      Returns:
      this CheckerString instance for chaining
    • isDigit

      public CheckerString isDigit()
      Checks if the string consists only of digits.
      Returns:
      this CheckerString instance for chaining
    • isDNI

      public CheckerString isDNI()
      Checks if the string is a valid Spanish DNI (8 digits followed by an uppercase letter).
      Returns:
      this CheckerString instance for chaining
    • isIPv4

      public CheckerString isIPv4()
      Checks if the string is a valid IPv4 address.
      Returns:
      this CheckerString instance for chaining
    • isIPv6

      public CheckerString isIPv6()
      Checks if the string is a valid IPv6 address.
      Returns:
      this CheckerString instance for chaining
    • hasSpecialCharacters

      public CheckerString hasSpecialCharacters()
      Checks if the string contains any special characters (e.g., !@#$%^&* etc.).
      Returns:
      this CheckerString instance for chaining
    • isPalindrome

      public CheckerString isPalindrome()
      Checks if the string is a palindrome (reads the same forwards and backwards).
      Returns:
      this CheckerString instance for chaining