Interface ValueMasker

All Known Implementing Classes:
RegexValueMasker
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ValueMasker
Masks JSON string and number values within a JSON stream. Invoked by MaskingJsonGenerator before a number or string value is written to determine if the value should be masked.

Comparison with FieldMasker:

  • Method Summary

    Modifier and Type
    Method
    Description
    mask(JsonStreamContext context, Object value)
    If the given value at the JSON stream context's current path should be masked, then returns the masked value to write as the value..
  • Method Details

    • mask

      Object mask(JsonStreamContext context, Object value)
      If the given value at the JSON stream context's current path should be masked, then returns the masked value to write as the value.. The MaskingJsonGenerator will write the returned masked value as the value (instead of the original value).

      If the given value at the JSON stream context's current path should NOT be masked, returns null.

      Parameters:
      context - the current JSON stream context, which can be used to determine the path within the JSON output. (could be at a field value path or an array element value path)
      value - the number or string scalar value to potentially mask (could be a field value or an array element value).
      Returns:
      A non-null masked value to write if given value at the JSON stream context's current path should be masked. Otherwise null if the given value at the JSON stream context's current path should NOT be masked. To write a JSON null value as the masked value, return NullNode.instance. To write "****", the return MaskingJsonGenerator.MASK