77d4ff492b63af655f07844faa9bd457e9997fc7
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / TerminationReason.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep;
9
10 import com.google.common.collect.Maps;
11
12 import java.util.Map;
13
14 public enum TerminationReason {
15     Unknown((short) 1), ExpDeadtimer((short) 2), MalformedMsg((short) 3), TooManyUnknownReqRep((short) 4), TooManyUnknownMsg((short) 5);
16
17     private short value;
18     private static final Map<Short, TerminationReason> valueMap;
19
20     static {
21         valueMap = Maps.newHashMap();
22         for (final TerminationReason enumItem : TerminationReason.values()) {
23             valueMap.put(enumItem.value, enumItem);
24         }
25     }
26
27     private TerminationReason(final short value) {
28         this.value = value;
29     }
30
31     /**
32      * @return integer value
33      */
34     public short getShortValue() {
35         return this.value;
36     }
37
38     /**
39      * @param valueArg
40      * @return corresponding TerminationReason item
41      */
42     public static TerminationReason forValue(final short valueArg) {
43         return valueMap.get(valueArg);
44     }
45 }