private static String calculateNewName(TreeMap<Pair<Integer, Integer>, String> replacements,
                                         final String[] propertyWords,
                                         String propertyName) {
    StringBuffer resultingWords = new StringBuffer();
    int currentWord = 0;
    final Pair<int[], int[]> wordIndices = calculateWordPositions(propertyName, propertyWords);
    for (final Map.Entry<Pair<Integer, Integer>, String> entry : replacements.entrySet()) {
      final int first = entry.getKey().getFirst().intValue();
      final int last = entry.getKey().getSecond().intValue();
      for (int i = currentWord; i < first; i++) {
        resultingWords.append(calculateBetween(wordIndices, i, propertyName));
        final String propertyWord = propertyWords[i];
        appendWord(resultingWords, propertyWord);
      }
      resultingWords.append(calculateBetween(wordIndices, first, propertyName));
      appendWord(resultingWords, entry.getValue());
      currentWord = last + 1;
    }
    for (; currentWord < propertyWords.length; currentWord++) {
      resultingWords.append(calculateBetween(wordIndices, currentWord, propertyName));
      appendWord(resultingWords, propertyWords[currentWord]);
    }
    resultingWords.append(calculateBetween(wordIndices, propertyWords.length, propertyName));
    if (resultingWords.isEmpty()) return propertyName;
    return decapitalizeProbably(resultingWords.toString(), propertyName);
  }
private static String calculateNewName(TreeMap<Pair<Integer, Integer>, String> replacements,
                                         final String[] propertyWords,
                                         String propertyName)