Class RegexNameRewriter

  • All Implemented Interfaces:
    NameRewriter

    public final class RegexNameRewriter
    extends Object
    implements NameRewriter
    A simple regular expression-based name rewriter.
    • Field Detail

      • pattern

        private final Pattern pattern
      • replacement

        private final String replacement
      • replaceAll

        private final boolean replaceAll
    • Constructor Detail

      • RegexNameRewriter

        public RegexNameRewriter​(Pattern pattern,
                                 String replacement,
                                 boolean replaceAll)
        Construct a new instance.
        Parameters:
        pattern - the substitution pattern (must not be null)
        replacement - the replacement string
        replaceAll - true to replace all occurrences of the pattern; false to replace only the first occurrence
    • Method Detail

      • rewriteName

        public String rewriteName​(String original)
        Rewrite a name. Must not return null.
        Specified by:
        rewriteName in interface NameRewriter
        Parameters:
        original - the original name
        Returns:
        the rewritten name
      • getPattern

        public Pattern getPattern()
        Get the pattern.
        Returns:
        the pattern
      • getReplacement

        public String getReplacement()
        Get the replacement string.
        Returns:
        the replacement string