Enum Class MaskingStrategy

java.lang.Object
java.lang.Enum<MaskingStrategy>
br.com.seedgrid.privacy.masking.MaskingStrategy
All Implemented Interfaces:
Serializable, Comparable<MaskingStrategy>, Constable

public enum MaskingStrategy extends Enum<MaskingStrategy>
Estratégias de mascaramento de dados pessoais, em nível de valor (string → string).

Antiga AuditRuleTypeEnum do audit — agora agnóstica de JSON/Jackson. A escrita/remoção no documento é responsabilidade do PersonalDataSanitizer; aqui só transformamos o valor.

REMOVE é estrutural (não transforma valor) — maskValue(String, String) devolve null e isRemoval() sinaliza ao chamador que o campo deve sair.

  • Enum Constant Details

    • FULL

      public static final MaskingStrategy FULL
      Substitui todo o valor por um fixo (default "***"). Ex.: "12345678900" → "***"
    • FORMAT

      public static final MaskingStrategy FORMAT
      Preserva o formato (CPF, telefone etc) usando o próprio param como máscara pronta. Ex.: param "***.***.***-**" → "***.***.***-**"
    • PARTIAL

      public static final MaskingStrategy PARTIAL
      Mostra apenas os últimos N caracteres (param = N, default 2). Ex.: "12345678900" (N=3) → "********900"
    • HASH

      public static final MaskingStrategy HASH
      Hash irreversível (SHA-256 hex) — LGPD safe para lookup sem revelar o valor.
    • TEMPLATE

      public static final MaskingStrategy TEMPLATE
      Gabarito posicional: '#' revela o caractere do valor naquela posição, '*' mascara, qualquer outro caractere é literal. Ex.: valor "LUCIANO", param "##*****" → "LU*****"
    • REMOVE

      public static final MaskingStrategy REMOVE
      Remove o campo por completo (estrutural). maskValue(java.lang.String, java.lang.String) devolve null.
  • Method Details

    • values

      public static MaskingStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MaskingStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • maskValue

      public abstract String maskValue(String value, String param)
      Transforma o valor conforme a estratégia. Para REMOVE devolve null (o chamador deve remover o campo — ver isRemoval()).
    • isRemoval

      public boolean isRemoval()
      true apenas para REMOVE (operação estrutural, não de valor).
    • notBlank

      protected static boolean notBlank(String s)
    • extractVisible

      protected int extractVisible(String param)
    • applyTemplate

      protected static String applyTemplate(String value, String template)