Move netconf.api.monitoring
[netconf.git] / protocol / netconf-server / src / main / java / org / opendaylight / netconf / server / 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.server.api.monitoring;
9
10 /**
11  * Class represents change in a {@link NetconfManagementSession}.
12  */
13 public final class SessionEvent {
14     private final NetconfManagementSession session;
15     private final Type type;
16
17     private SessionEvent(final NetconfManagementSession session, final 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(final NetconfManagementSession session) {
41         return new SessionEvent(session, Type.IN_RPC_SUCCESS);
42     }
43
44     public static SessionEvent inRpcFail(final NetconfManagementSession session) {
45         return new SessionEvent(session, Type.IN_RPC_FAIL);
46     }
47
48     public static SessionEvent outRpcError(final NetconfManagementSession session) {
49         return new SessionEvent(session, Type.OUT_RPC_ERROR);
50     }
51
52     public static SessionEvent notification(final NetconfManagementSession session) {
53         return new SessionEvent(session, Type.NOTIFICATION);
54     }
55
56     /**
57      * Session event type.
58      */
59     public enum Type {
60         /**
61          * Correct rpc message received.
62          */
63         IN_RPC_SUCCESS,
64
65         /**
66          * Incorrect rpc message received.
67          */
68         IN_RPC_FAIL,
69
70         /**
71          * rpc-reply messages sent that contained an rpc-error element.
72          */
73         OUT_RPC_ERROR,
74
75         /**
76          * Notification message sent.
77          */
78         NOTIFICATION
79     }
80 }