List<ArrangementSectionRule> () { if (getModel().getSize() <= 0) { return Collections.emptyList(); } final List<ArrangementSectionRule> result = new ArrayList<>(); final List<StdArrangementMatchRule> buffer = new ArrayList<>(); String currentSectionStart = null; for (int i = 0; i < getModel().getSize(); i++) { final Object element = getModel().getElementAt(i); if (element instanceof StdArrangementMatchRule) { final ArrangementSectionRuleData sectionRule = mySectionRuleManager == null ? null : mySectionRuleManager.getSectionRuleData((StdArrangementMatchRule)element); if (sectionRule != null) { if (sectionRule.isSectionStart()) { appendBufferedSectionRules(result, buffer, currentSectionStart); currentSectionStart = sectionRule.getText(); } else { result.add(ArrangementSectionRule.create(StringUtil.notNullize(currentSectionStart), sectionRule.getText(), buffer)); buffer.clear(); currentSectionStart = null; } } else { if (currentSectionStart == null) { result.add(ArrangementSectionRule.create((StdArrangementMatchRule)element)); } else { buffer.add((StdArrangementMatchRule)element); } } } } appendBufferedSectionRules(result, buffer, currentSectionStart); return result; }