Integrate netconf-mapping-api into netconf-server
[netconf.git] / protocol / netconf-api / src / main / java / org / opendaylight / netconf / api / monitoring / SessionEvent.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 package org.opendaylight.netconf.api.monitoring;
9
10 /**
11  * Class represents change in netconf session.
12  */
13 public final class SessionEvent {
14     private final NetconfManagementSession session;
15     private final Type type;
16
17     private SessionEvent(NetconfManagementSession session, Type type) {
18         this.session = session;
19         this.type = type;
20     }
21
22     /**
23      * Returns session, where event occurred.
24      *
25      * @return session
26      */
27     public NetconfManagementSession getSession() {
28         return session;
29     }
30
31     /**
32      * Returns event type.
33      *
34      * @return type
35      */
36     public Type getType() {
37         return type;
38     }
39
40     public static SessionEvent inRpcSuccess(NetconfManagementSession session) {
41         return new SessionEvent(session, Type.IN_RPC_SUCCESS);
42     }
43
44     public static SessionEvent inRpcFail(NetconfManagementSession session) {
45         return new SessionEvent(session, Type.IN_RPC_FAIL);
46     }
47
48     public static SessionEvent outRpcError(NetconfManagementSession session) {
49         return new SessionEvent(session, Type.OUT_RPC_ERROR);
50     }
51
52     public static SessionEvent notification(NetconfManagementSession session) {
53         return new SessionEvent(session, Type.NOTIFICATION);
54     }
55
56     /**
57      * Session event type.
58      */
59     public enum Type {
60
61         /**
62          * Correct rpc message received.
63          */
64         IN_RPC_SUCCESS,
65
66         /**
67          * Incorrect rpc message received.
68          */
69         IN_RPC_FAIL,
70
71         /**
72          * rpc-reply messages sent that contained an rpc-error element.
73          */
74         OUT_RPC_ERROR,
75
76         /**
77          * Notification message sent.
78          */
79         NOTIFICATION
80     }
81 }