Class Replacements

java.lang.Object
org.approvej.scrub.Replacements

@NullMarked public class Replacements extends Object
Collection of replacement functions (Functions that take an Integer and return an Object) for use with Scrubbers.
  • Method Details

    • numbered

      public static Replacement<String> numbered(String label)
      Replaces with "[label #]" where label is the given label and # is the number of the distinct replacement.
      Parameters:
      label - a String used to identify the replacement
      Returns:
      a replacement function that replaces with "[label #]"
    • numbered

      public static Replacement<String> numbered()
      Replaces each match with "[scrubbed #]" where # is the number of the distinct replacement.
      Returns:
      a replacement function that replaces with "[scrubbed #]"
    • labeled

      public static Replacement<String> labeled(String label)
      Replaces with "[label]" where "label" is the given label.
      Parameters:
      label - a String used to identify the replacement
      Returns:
      a replacement function that replaces with "[label]"
    • string

      public static Replacement<String> string(String replacement)
      Replaces each match with the given static replacement string.
      Parameters:
      replacement - the static replacement string
      Returns:
      a replacement function that always returns the same string
    • relativeDate

      public static RelativeDateReplacement relativeDate()
      Replaces each match of the DateTimeScrubber with a relative duration, like [today], [yesterday], [in 13 days], [1 year 20 days ago].
      Returns:
      a new RelativeDateReplacement
    • relativeDateTime

      public static RelativeDateTimeReplacement relativeDateTime()
      Replaces each match of the DateTimeScrubber with a relative duration, like [now], [in 1d 23h 59m 59s], [10s ago].
      Returns:
      a new RelativeDateTimeReplacement
    • masking

      public static Replacement<String> masking()
      Masks each letter or digit of the match with a generic one. E.g. all latin uppercase letters are replaced with A, hence the String "John Doe" is replaced with "Aaaa Aaa".

      This Replacement is generally useful for well-structured strings that do not vary in length or composition like order numbers, IDs, or strict date/time strings. It is not a good choice for names as they usually vary in length, or UUIDs as they are composed of random characters and digits (hexadecimal).

      Returns:
      a replacement function replaces each character with a generic one