private String generateResult() {
    StringBuilder result;
    if (myConversionRegions.isEmpty()) {
      result = myReplacement;
    }
    else {
      CaseConversionRegion lastRegion = myConversionRegions.get(myConversionRegions.size() - 1);
      if (lastRegion.end < 0 || lastRegion.end > myReplacement.length()) {
        lastRegion.end = myReplacement.length();
      }
      result = new StringBuilder();
      int currentOffset = 0;
      for (CaseConversionRegion conversionRegion : myConversionRegions) {
        result.append(myReplacement, currentOffset, conversionRegion.start);
        String region = myReplacement.substring(conversionRegion.start, conversionRegion.end);
        result.append(conversionRegion.toUpperCase ? region.toUpperCase(Locale.getDefault()) : region.toLowerCase(Locale.getDefault()));
        currentOffset = conversionRegion.end;
      }
      result.append(myReplacement, currentOffset, myReplacement.length());
    }
    return result.toString();
  }
private String generateResult()