@VisibleForTesting
  static Pattern buildPattern( boolean literalParsing, boolean caseSensitive, boolean wholeWord,
    String patternString, boolean isUnicode ) {
    int flags = 0;
    if ( literalParsing && !wholeWord ) {
      flags |= Pattern.LITERAL;
    }
    if ( !caseSensitive ) {
      flags |= Pattern.CASE_INSENSITIVE;
    }
    if ( isUnicode ) {
      flags |= Pattern.UNICODE_CHARACTER_CLASS;
    }

    /*
     * XXX: I don't like this parameter. I think it would almost always be better for the user to define either word
     * boundaries or ^/$ anchors explicitly in their pattern.
     */
    if ( wholeWord ) {
      if ( literalParsing ) {
        patternString = "\\Q" + patternString + "\\E";
      }
      patternString = "\\b" + patternString + "\\b";
    }

    return Pattern.compile( patternString, flags );
  }
@Test
  public void testBuildPatternWithNonLiteralParsingAndWholeWord() {
    Pattern actualPattern = ReplaceString.buildPattern( false, true, true, LITERAL_STRING, false );
    Matcher matcher = actualPattern.matcher( INPUT_STRING );
    String actualString = matcher.replaceAll( "are" );
    assertEquals( "This are String This Is String THIS IS STRING", actualString );
  }