Class UuidScrubber

java.lang.Object
org.approvej.scrub.UuidScrubber

@NullMarked public class UuidScrubber extends Object
Scrubs a String by replacing all occurrences UUIDs.

E.g.

   {
     "id": "123e4567-e89b-12d3-a456-426614174000",
     "other-id": "123e4567-e89b-12d3-a456-426614174001",
     "same-id": "123e4567-e89b-12d3-a456-426614174000"
   }
 

Will be scrubbed to

   {
     "id": "[uuid 1]",
     "other-id": "[uuid 2]",
     "same-id": "[uuid 1]"
   }
 
  • Field Details

    • NUMBERED_REPLACEMENT

      public static final Function<Integer,String> NUMBERED_REPLACEMENT
      Replaces each match with "[uuid #]" where '#' is the number of the distinct found string.
  • Method Details

    • uuids

      public static RegexScrubber uuids(Function<Integer,String> replacement)
      Creates a new RegexScrubber using the given replacement function.
      Parameters:
      replacement - a custom replacement function that takes the number of the match as an argument
      Returns:
      a RegexScrubber that replaces all UUIDs with the given replacement
    • uuids

      public static RegexScrubber uuids()
      Creates a new RegexScrubber using the NUMBERED_REPLACEMENT.
      Returns:
      a RegexScrubber that replaces all UUIDs with a numbered placeholder