Package org.approvej.scrub
Class Replacements
java.lang.Object
org.approvej.scrub.Replacements
-
Method Summary
Modifier and TypeMethodDescriptionstatic Replacement
masking()
Masks each letter or digit of the match with a generic one.static Replacement
numbered()
Replaces each match with "[scrubbed #]" where '#' is the number of the distinct replacement.static Replacement
Replaces with "[label #]
" wherelabel
is the given label and '#' is the number of the distinct replacement.static Replacement
relativeDate
(String dateTimePattern) Replaces each match of the given dateTimePattern (as defined byDateTimeFormatter
) with a relative description, like[today]
,[yesterday]
,[13 days from now]
.static Replacement
relativeDate
(DateTimeFormatter dateTimeFormatter) Replaces each match of the given dateTimePattern (as defined byDateTimeFormatter
) with a relative description, like[today]
,[yesterday]
,[13 days from now]
.static Replacement
Replaces each match with the given static replacement string.
-
Method Details
-
numbered
Replaces with "[label #]
" wherelabel
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
Replaces each match with "[scrubbed #]" where '#' is the number of the distinct replacement.- Returns:
- a replacement function that replaces with "[scrubbed #]"
-
string
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
Replaces each match of the given dateTimePattern (as defined byDateTimeFormatter
) with a relative description, like[today]
,[yesterday]
,[13 days from now]
.- Parameters:
dateTimeFormatter
- theDateTimeFormatter
to parse the date/time strings- Returns:
- a replacement function that returns a relative description for dates of the given dateTimePattern
-
relativeDate
Replaces each match of the given dateTimePattern (as defined byDateTimeFormatter
) with a relative description, like[today]
,[yesterday]
,[13 days from now]
.- Parameters:
dateTimePattern
- a pattern as defined byDateTimeFormatter
- Returns:
- a replacement function that returns a relative description for dates of the given dateTimePattern
-
masking
Masks each letter or digit of the match with a generic one. E.g. all latin uppercase letters are replaced withA
, 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
-