void () { // Inspired by IDEA-91826. ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition(); ArrangementSettingsToken typeToPreserve = FIELD; Set<ArrangementSettingsToken> modifiersToPreserve = ContainerUtil.newHashSet(PUBLIC, STATIC, FINAL); condition.addOperand(new ArrangementAtomMatchCondition(typeToPreserve, typeToPreserve)); for (ArrangementSettingsToken modifier : modifiersToPreserve) { condition.addOperand(new ArrangementAtomMatchCondition(modifier, modifier)); } Element element = mySerializer.serialize(new StdArrangementEntryMatcher(condition)); assertNotNull(element); // Change hash-container data distribution at the composite condition. for (ArrangementSettingsToken type : StdArrangementTokens.EntryType.values()) { if (type != typeToPreserve) { condition.addOperand(new ArrangementAtomMatchCondition(type, type)); } } for (ArrangementSettingsToken modifier : StdArrangementTokens.Modifier.values()) { if (!modifiersToPreserve.contains(modifier)) { condition.addOperand(new ArrangementAtomMatchCondition(modifier, modifier)); } } // Revert state to the initial one. for (ArrangementSettingsToken type : StdArrangementTokens.EntryType.values()) { if (type != typeToPreserve) { condition.removeOperand(new ArrangementAtomMatchCondition(type, type)); } } for (ArrangementSettingsToken modifier : StdArrangementTokens.Modifier.values()) { if (!modifiersToPreserve.contains(modifier)) { condition.removeOperand(new ArrangementAtomMatchCondition(modifier, modifier)); } } // Check that the order is the same Element actual = mySerializer.serialize(new StdArrangementEntryMatcher(condition)); assertNotNull(actual); checkElements(element, actual); }