code: public String mask(final String value,
                         final String replacementValue) {
  
          try {
  
              if (hasMasks()) {
  
                  if (value == null) return null;
  
                  String maskedValue = value;
  
                  for (Map.Entry<String, Pattern> entry : maskPatterns.entrySet()) {
                      Matcher matcher = entry.getValue().matcher(maskedValue);
                      while (matcher.find()) {
  
                          String match = matcher.group();
                          String matchReplace;
  
                          if (replacementValue.length() == 1) {
                              char[] symbols = new char[match.length()];
                              Arrays.fill(symbols, replacementValue.toCharArray()[0]);
                              matchReplace = new String(symbols);
                          } else {
                              matchReplace = replacementValue;
                          }
  
                          maskedValue = maskedValue.replace(match, matchReplace);
                      }
                  }
  
                  return maskedValue;
              }
  
          } catch (Throwable e) {
              log.warn(e.getMessage(), e);
          }
  
          return value;
      }
docs: Returns string with [replacementValue] replacing any value matching a configured mask.
  
  @param value            Value to mask.
  @param replacementValue Value to use when replacing original content.
  If a single character string is supplied, it will be repeated to keep original value's length.