Enforce checkstyle and findbug under PCE Api
[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 import java.util.Map;
12
13 public enum TerminationReason {
14     UNKNOWN((short) 1),
15     EXP_DEADTIMER((short) 2),
16     MALFORMED_MSG((short) 3),
17     TOO_MANY_UNKNWN_REQS((short) 4),
18     TOO_MANY_UNKNOWN_MSGS((short) 5);
19
20     private static final Map<Short, TerminationReason> VALUE_MAP;
21
22     static {
23         VALUE_MAP = Maps.newHashMap();
24         for (final TerminationReason enumItem : TerminationReason.values()) {
25             VALUE_MAP.put(enumItem.value, enumItem);
26         }
27     }
28
29     private short value;
30
31     TerminationReason(final short value) {
32         this.value = value;
33     }
34
35     /**
36      * Gets termination reason for specific short value.
37      *
38      * @param valueArg corresponding to Termination reason
39      * @return corresponding TerminationReason item
40      */
41     public static TerminationReason forValue(final short valueArg) {
42         return VALUE_MAP.get(valueArg);
43     }
44
45     /**
46      * Gets value of termination reason.
47      *
48      * @return short value
49      */
50     public short getShortValue() {
51         return this.value;
52     }
53 }