Fixup Augmentable and Identifiable methods changing
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / State.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.rib.spi;
10
11 import com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13
14 /**
15  * Internal session state.
16  */
17 public enum State {
18     /**
19      * The session object is created by the negotiator in OpenConfirm state. While in this state, the session object
20      * is half-alive, e.g. the timers are running, but the session is not completely up, e.g. it has not been
21      * announced to the listener. If the session is torn down in this state, we do not inform the listener.
22      */
23     OPEN_CONFIRM((short) 0),
24     /**
25      * The session has been completely established.
26      */
27     UP((short) 1),
28     /**
29      * The session has been closed. It will not be resurrected.
30      */
31     IDLE((short) 2);
32
33     private static final Map<Short, State> VALUE_MAP;
34
35     static {
36         final ImmutableMap.Builder<Short, State> b = ImmutableMap.builder();
37         for (final State enumItem : State.values()) {
38             b.put(enumItem.getValue(), enumItem);
39         }
40         VALUE_MAP = b.build();
41     }
42
43     private final short value;
44
45     State(final short value) {
46         this.value = value;
47     }
48
49     public static State forValue(final short value) {
50         return VALUE_MAP.get(value);
51     }
52
53     public short getValue() {
54         return this.value;
55     }
56 }