Source:
private void finishImportList() { final ImportDetails firstImport = importToGroupList.get(0); String currentGroup = getImportGroup(firstImport.isStaticImport(), firstImport.getImportFullPath()); int currentGroupNumber = customImportOrderRules.indexOf(currentGroup); ImportDetails previousImportObjectFromCurrentGroup = null; String previousImportFromCurrentGroup = null; for (final ImportDetails importObject : importToGroupList) { final String importGroup = importObject.getImportGroup(); final String fullImportIdent = importObject.getImportFullPath(); if (importGroup.equals(currentGroup)) { if (previousImportObjectFromCurrentGroup != null && getCountOfEmptyLinesBetween( previousImportObjectFromCurrentGroup.getLineNumber(), importObject.getLineNumber()) > 1) { log(importObject.getLineNumber(), MSG_SEPARATED_INTERNALLY, fullImportIdent); } if (sortImportsInGroupAlphabetically && previousImportFromCurrentGroup != null && compareImports(fullImportIdent, previousImportFromCurrentGroup) < 0) { log(importObject.getLineNumber(), MSG_LEX, fullImportIdent, previousImportFromCurrentGroup); } else { previousImportFromCurrentGroup = fullImportIdent; } previousImportObjectFromCurrentGroup = importObject; } else { if (customImportOrderRules.size() > currentGroupNumber + 1) { final String nextGroup = getNextImportGroup(currentGroupNumber + 1); if (importGroup.equals(nextGroup)) { if (separateLineBetweenGroups && getCountOfEmptyLinesBetween( previousImportObjectFromCurrentGroup.getLineNumber(), importObject.getLineNumber()) != 1) { log(importObject.getLineNumber(), MSG_LINE_SEPARATOR, fullImportIdent); } currentGroup = nextGroup; currentGroupNumber = customImportOrderRules.indexOf(nextGroup); previousImportFromCurrentGroup = fullImportIdent; } else { logWrongImportGroupOrder(importObject.getLineNumber(), importGroup, nextGroup, fullImportIdent); } previousImportObjectFromCurrentGroup = importObject; } else { logWrongImportGroupOrder(importObject.getLineNumber(), importGroup, currentGroup, fullImportIdent); } } } }

Target:
private void finishImportList() { String currentGroup = getFirstGroup(); int currentGroupNumber = customImportOrderRules.indexOf(currentGroup); ImportDetails previousImportObjectFromCurrentGroup = null; String previousImportFromCurrentGroup = null; for (ImportDetails importObject : importToGroupList) { final String importGroup = importObject.getImportGroup(); final String fullImportIdent = importObject.getImportFullPath(); if (importGroup.equals(currentGroup)) { if (isSeparatedByExtraEmptyLine(previousImportObjectFromCurrentGroup, importObject)) { log(importObject.getLineNumber(), MSG_LINE_SEPARATOR, fullImportIdent); } if (isAlphabeticalOrderBroken(previousImportFromCurrentGroup, fullImportIdent)) { log(importObject.getLineNumber(), MSG_LEX, fullImportIdent, previousImportFromCurrentGroup); } else { previousImportFromCurrentGroup = fullImportIdent; } previousImportObjectFromCurrentGroup = importObject; } else { if (customImportOrderRules.size() > currentGroupNumber + 1) { final String nextGroup = getNextImportGroup(currentGroupNumber + 1); if (importGroup.equals(nextGroup)) { if (isEmptyLineMissed(previousImportObjectFromCurrentGroup, importObject)) { log(importObject.getLineNumber(), MSG_LINE_SEPARATOR, fullImportIdent); } currentGroup = nextGroup; currentGroupNumber = customImportOrderRules.indexOf(nextGroup); previousImportFromCurrentGroup = fullImportIdent; } else { logWrongImportGroupOrder(importObject.getLineNumber(), importGroup, nextGroup, fullImportIdent); } previousImportObjectFromCurrentGroup = importObject; } else { logWrongImportGroupOrder(importObject.getLineNumber(), importGroup, currentGroup, fullImportIdent); } } } }