Record Class SecretPattern

java.lang.Object
java.lang.Record
com.tnsai.quality.security.SecretPattern
Record Components:
name - human-readable name for this secret type
pattern - compiled regex that matches the secret
placeholder - redaction placeholder (e.g. [REDACTED:api_key])
enabled - whether this pattern is active

public record SecretPattern(String name, Pattern pattern, String placeholder, boolean enabled) extends Record
Defines a single secret detection pattern.

Each pattern has a name, a compiled regex, and a placeholder format used when redacting matches (e.g. [REDACTED:api_key]).

Since:
0.2.3
  • Constructor Details

    • SecretPattern

      public SecretPattern(String name, Pattern pattern, String placeholder, boolean enabled)
      Compact constructor with validation.
  • Method Details

    • of

      public static SecretPattern of(String name, String regex, String secretType)
      Creates an enabled pattern.
      Parameters:
      name - human-readable name
      regex - regex string
      secretType - type label used in placeholder
      Returns:
      enabled SecretPattern
    • withDisabled

      public SecretPattern withDisabled()
      Creates a disabled copy of this pattern.
      Returns:
      disabled SecretPattern
    • withEnabled

      public SecretPattern withEnabled()
      Creates an enabled copy of this pattern.
      Returns:
      enabled SecretPattern
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • pattern

      public Pattern pattern()
      Returns the value of the pattern record component.
      Returns:
      the value of the pattern record component
    • placeholder

      public String placeholder()
      Returns the value of the placeholder record component.
      Returns:
      the value of the placeholder record component
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component