*/
package org.opendaylight.protocol.pcep.spi;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
-import java.util.Map;
+import java.util.Arrays;
/**
* Possible errors listed in RFC5440, RFC 5455 and stateful draft.
*/
INVALID_LSP_DB_VERSION(20, 7);
- private PCEPErrorIdentifier errorId;
- private static final Map<PCEPErrorIdentifier, PCEPErrors> VALUE_MAP;
+ private static final ImmutableMap<PCEPErrorIdentifier, PCEPErrors> VALUE_MAP = Maps.uniqueIndex(
+ Arrays.asList(values()), PCEPErrors::getErrorIdentifier);
- static {
- VALUE_MAP = Maps.newHashMap();
- for (final PCEPErrors enumItem : PCEPErrors.values()) {
- VALUE_MAP.put(enumItem.getErrorIdentifier(), enumItem);
- }
- }
+ private PCEPErrorIdentifier errorId;
public static PCEPErrors forValue(final short errorType, final short errorValue) {
return VALUE_MAP.get(new PCEPErrorIdentifier(errorType, errorValue));