Class CheckerColor

java.lang.Object
util.AbstractChecker<Color,CheckerColor>
specialized_checkers.CheckerColor
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Color,CheckerColor>,Color>

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

It provides a fluent API for common color validations such as checking color equality, brightness, transparency, contrast, and more.

  • Constructor Details

    • CheckerColor

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

    • check

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

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

      protected CheckerColor self()
      Returns this instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<Color,CheckerColor>
      Returns:
      this CheckerColor instance
    • isBlack

      public CheckerColor isBlack()
      Checks if the color is black.
      Returns:
      this CheckerColor instance for chaining
    • isWhite

      public CheckerColor isWhite()
      Checks if the color is white.
      Returns:
      this CheckerColor instance for chaining
    • isGray

      public CheckerColor isGray()
      Checks if the color is a shade of gray (red, green, and blue components are equal).
      Returns:
      this CheckerColor instance for chaining
    • isColor

      public CheckerColor isColor(Color other)
      Checks if the color is equal to another color.
      Parameters:
      other - the color to compare with
      Returns:
      this CheckerColor instance for chaining
    • isDark

      public CheckerColor isDark()
      Checks if the color is considered dark using the default threshold (128).
      Returns:
      this CheckerColor instance for chaining
    • isDark

      public CheckerColor isDark(double umbral)
      Checks if the color is considered dark using the specified threshold.
      Parameters:
      umbral - the threshold for darkness (lower value means darker)
      Returns:
      this CheckerColor instance for chaining
    • isLight

      public CheckerColor isLight()
      Checks if the color is considered light using the default threshold (128).
      Returns:
      this CheckerColor instance for chaining
    • isLight

      public CheckerColor isLight(double umbral)
      Checks if the color is considered light using the specified threshold.
      Parameters:
      umbral - the threshold for lightness (higher value means lighter)
      Returns:
      this CheckerColor instance for chaining
    • isTransparent

      public CheckerColor isTransparent()
      Checks if the color is transparent (alpha value less than 255).
      Returns:
      this CheckerColor instance for chaining
    • hasContrast

      public CheckerColor hasContrast(Color other)
      Checks if the color has sufficient contrast with another color using the default threshold (128).
      Parameters:
      other - the color to compare contrast with
      Returns:
      this CheckerColor instance for chaining
    • hasContrast

      public CheckerColor hasContrast(Color other, double umbral)
      Checks if the color has sufficient contrast with another color using the specified threshold.
      Parameters:
      other - the color to compare contrast with
      umbral - the threshold for contrast difference
      Returns:
      this CheckerColor instance for chaining
    • hasAlpha

      public CheckerColor hasAlpha(int alpha)
      Checks if the color has the specified alpha (transparency) value.
      Parameters:
      alpha - the expected alpha value
      Returns:
      this CheckerColor instance for chaining
    • isDesaturated

      public CheckerColor isDesaturated(double umbral)
      Checks if the color is desaturated (saturation below the specified threshold).
      Parameters:
      umbral - the threshold for saturation (0 = grayscale, 1 = fully saturated)
      Returns:
      this CheckerColor instance for chaining
    • isSimilar

      public CheckerColor isSimilar(Color other, double umbral)
      Checks if the color is similar to another color within the specified threshold.
      Parameters:
      other - the color to compare with
      umbral - the maximum allowed distance for similarity
      Returns:
      this CheckerColor instance for chaining
    • isOpaque

      public CheckerColor isOpaque()
      Checks if the color is fully opaque (alpha value is 255).
      Returns:
      this CheckerColor instance for chaining
    • hasHexadecimal

      public CheckerColor hasHexadecimal(String hex)
      Checks if the color's hexadecimal representation matches the specified string.
      Parameters:
      hex - the expected hexadecimal string (e.g., "#FFFFFF")
      Returns:
      this CheckerColor instance for chaining