Feature uses features-parent as parent
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / lib / messages / IdentityRequest.java
1 /*
2  * Copyright (C) 2014 Cisco Systems, Inc.
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  * Authors : Thomas Bachman
9  */
10 package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15 import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage;
16
17 import com.fasterxml.jackson.annotation.JsonIgnore;
18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
20 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
21
22 @JsonSerialize
23 @JsonDeserialize
24 public class IdentityRequest extends RpcMessage {
25
26     public static final String IDENTITY_MESSAGE = "send_identity";
27     public static final String OPFLEX_PROTOCOL_VERSION = "1.0";
28
29     static public class Params {
30
31         private final String proto_version;
32         private String name;
33         private String domain;
34         private List<String> my_role;
35
36         public String getName() {
37             return this.name;
38         }
39
40         public void setName(String name) {
41             this.name = name;
42         }
43
44         public Params() {
45             this.proto_version = OPFLEX_PROTOCOL_VERSION;
46             my_role = new ArrayList<String>();
47         }
48
49         public String getProto_version() {
50             return proto_version;
51         }
52
53         public String getDomain() {
54             return domain;
55         }
56
57         public void setDomain(String domain) {
58             this.domain = domain;
59         }
60
61         public List<String> getMy_role() {
62             return my_role;
63         }
64
65         public void setMy_role(List<String> my_role) {
66             this.my_role = my_role;
67         }
68
69     }
70
71     private JsonNode id;
72     private String method;
73     private List<Params> params;
74
75     @JsonIgnore
76     private String name;
77
78     @Override
79     public JsonNode getId() {
80         return id;
81     }
82
83     @Override
84     public void setId(JsonNode id) {
85         this.id = id;
86     }
87
88     @Override
89     public String getMethod() {
90         return method;
91     }
92
93     @Override
94     public void setMethod(String method) {
95         this.method = method;
96     }
97
98     public List<Params> getParams() {
99         return this.params;
100     }
101
102     public void setParams(List<Params> params) {
103         this.params = params;
104     }
105
106     @Override
107     public String getName() {
108         return this.name;
109     }
110
111     @Override
112     public void setName(String name) {
113         this.name = name;
114     }
115
116     public IdentityRequest(String name) {
117         this.name = name;
118     }
119
120     public IdentityRequest() {
121         this.name = IDENTITY_MESSAGE;
122         this.method = IDENTITY_MESSAGE;
123     }
124
125     /**
126      * Minimal check on validity of message
127      * 
128      * @return true if message has passed validity check
129      */
130     @JsonIgnore
131     @Override
132     public boolean valid() {
133         if (params == null)
134             return false;
135         if (params.get(0) == null)
136             return false;
137         return true;
138     }
139 }