Object2IntMap<HighlightSeverity> (@NotNull List<? extends HighlightSeverity> orderList) { if (orderList.isEmpty()) { return Object2IntMaps.emptyMap(); } Object2IntMap<HighlightSeverity> map = new Object2IntOpenHashMap<>(orderList.size()); map.defaultReturnValue(-1); for (int index = 0; index < orderList.size(); index++) { HighlightSeverity severity = orderList.get(index); map.put(severity, index); } if (map.size() != orderList.size()) { Logger.getInstance(SeverityRegistrar.class).error("Severities order list must contain unique severities but got: " + orderList); } return Object2IntMaps.unmodifiable(map); }