Object2IntMap<HighlightSeverity> (@NotNull List<? extends HighlightSeverity> read, @NotNull List<HighlightSeverity> knownSeverities) { Object2IntMap<HighlightSeverity> orderMap = fromList(read); if (orderMap.isEmpty()) { return fromList(knownSeverities); } // enforce include all known List<HighlightSeverity> list = getSortedSeverities(orderMap); for (HighlightSeverity stdSeverity : knownSeverities) { if (!list.contains(stdSeverity)) { for (int oIdx = 0; oIdx < list.size(); oIdx++) { HighlightSeverity orderSeverity = list.get(oIdx); if (orderSeverity.myVal > stdSeverity.myVal) { list.add(oIdx, stdSeverity); myReadOrder = null; break; } } } } return fromList(list); }