Separating renderers into features.
[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.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         private final String proto_version;
31         private String name;
32         private String domain;
33         private List<String> my_role;
34         public String getName() {
35             return this.name;
36         }
37
38         public void setName(String name) {
39             this.name = name;
40         }
41
42         public Params() {
43                 this.proto_version = OPFLEX_PROTOCOL_VERSION;
44             my_role = new ArrayList<String>();
45         }
46
47         public String getProto_version() {
48                 return proto_version;
49         }
50
51         public String getDomain() {
52             return domain;
53         }
54
55         public void setDomain(String domain) {
56             this.domain = domain;
57         }
58
59         public List<String> getMy_role() {
60             return my_role;
61         }
62
63         public void setMy_role(List<String> my_role) {
64             this.my_role = my_role;
65         }
66
67
68     }
69     private JsonNode id;
70     private String method;
71     private List<Params> params;
72
73     @JsonIgnore
74     private String name;
75
76     @Override
77     public JsonNode getId() {
78         return id;
79     }
80
81     @Override
82     public void setId(JsonNode id) {
83         this.id = id;
84     }
85
86     @Override
87     public String getMethod() {
88         return method;
89     }
90
91     @Override
92     public void setMethod(String method) {
93         this.method = method;
94     }
95
96     public List<Params> getParams() {
97         return this.params;
98     }
99
100     public void setParams(List<Params> params) {
101         this.params = params;
102     }
103
104     @Override
105     public String getName() {
106         return this.name;
107     }
108
109     @Override
110     public void setName(String name) {
111         this.name = name;
112     }
113
114     public IdentityRequest(String name) {
115         this.name = name;
116     }
117
118     public IdentityRequest() {
119         this.name = IDENTITY_MESSAGE;
120         this.method = IDENTITY_MESSAGE;
121     }
122
123     /**
124      * Minimal check on validity of message
125      * @return true if message has passed validity check
126      */
127     @JsonIgnore
128     @Override
129     public boolean valid() {
130         if (params == null)
131             return false;
132         if (params.get(0) == null)
133             return false;
134         return true;
135     }
136 }