Source:
public Match matchUri(@NonNull List<UrlElement> elements, @Nullable Map<String, String> placeholders, int elementIndex, int elementStartPosition, int parentBoundryPos, Map<String, String> pathSegmentReplacements) { Match match = null; int currentElementStartPosition = elementStartPosition; do { UrlElement urlElement = elements.get(elementIndex); CompareResult compareResult = compareValue(currentElementStartPosition, urlElement.getTypeFlag(), urlElement.getValue(), pathSegmentReplacements); if (compareResult != null) { Map<String, String> placeholdersOutput = placeholders; if (!compareResult.getPlaceholderValue().isEmpty()) { placeholdersOutput = new HashMap<>(placeholders != null ? placeholders : Collections.<String, String>emptyMap()); String[] compareParams = compareResult.getPlaceholderValue().split(MATCH_PARAM_DIVIDER_CHAR); placeholdersOutput.put(compareParams[0], compareParams[1]); } if (elementIndex < elements.size() - 1 || compareResult.isEmptyConfigurablePathSegmentMatch) { int childrenPos = getChildrenPos(currentElementStartPosition); if (childrenPos != -1) { match = matchUri(elements, placeholdersOutput, compareResult.isEmptyConfigurablePathSegmentMatch ? elementIndex : elementIndex + 1, childrenPos, getElementBoundaryPos(currentElementStartPosition), pathSegmentReplacements); } } else { int matchIndex = getMatchIndex(currentElementStartPosition); if (matchIndex == NO_MATCH) { return null; } match = new Match(matchIndex, placeholdersOutput == null ? new HashMap<String, String>(0) : placeholdersOutput); } } if (match != null) { return match; } currentElementStartPosition = getNextElementStartPosition(currentElementStartPosition, parentBoundryPos); } while (currentElementStartPosition != -1); return null; }

Target:
public Match matchUri(@NonNull List<UrlElement> elements, @Nullable Map<String, String> placeholders, int elementIndex, int elementStartPosition, int parentBoundryPos, Map<String, String> pathSegmentReplacements) { Match match = null; int currentElementStartPosition = elementStartPosition; do { UrlElement urlElement = elements.get(elementIndex); CompareResult compareResult = compareValue(currentElementStartPosition, urlElement.getTypeFlag(), urlElement.getValue(), pathSegmentReplacements); if (compareResult != null) { Map<String, String> placeholdersOutput = placeholders; if (!compareResult.getPlaceholderValue().isEmpty()) { placeholdersOutput = new HashMap<>(placeholders != null ? placeholders : Collections.<String, String>emptyMap()); String[] compareParams = compareResult.getPlaceholderValue().split(MATCH_PARAM_DIVIDER_CHAR); placeholdersOutput.put(compareParams[0], compareParams[1]); } if (elementIndex < elements.size() - 1 || compareResult.isEmptyConfigurablePathSegmentMatch()) { int childrenPos = getChildrenPos(currentElementStartPosition); if (childrenPos != -1) { match = matchUri(elements, placeholdersOutput, compareResult.isEmptyConfigurablePathSegmentMatch() ? elementIndex : elementIndex + 1, childrenPos, getElementBoundaryPos(currentElementStartPosition), pathSegmentReplacements); } } else { int matchIndex = getMatchIndex(currentElementStartPosition); if (matchIndex == NO_MATCH) { return null; } match = new Match(matchIndex, placeholdersOutput == null ? new HashMap<String, String>(0) : placeholdersOutput); } } if (match != null) { return match; } currentElementStartPosition = getNextElementStartPosition(currentElementStartPosition, parentBoundryPos); } while (currentElementStartPosition != -1); return null; }