Separating renderers into features.
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / lib / messages / EndpointDeclareRequest.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.List;
13
14 import org.opendaylight.groupbasedpolicy.jsonrpc.RpcMessage;
15
16 import com.fasterxml.jackson.annotation.JsonIgnore;
17 import com.fasterxml.jackson.databind.JsonNode;
18 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
19 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
20
21 @JsonSerialize
22 @JsonDeserialize
23 public class EndpointDeclareRequest extends RpcMessage {
24
25     public static final String DECLARE_MESSAGE = "endpoint_declare";
26
27     static public class Params {
28         private List<ManagedObject> endpoint;
29         private int prr;
30         public List<ManagedObject> getEndpoint() {
31             return endpoint;
32         }
33         public void setEndpoint(List<ManagedObject> endpoint) {
34             this.endpoint = endpoint;
35         }
36         public int getPrr() {
37             return prr;
38         }
39         public void setPrr(int prr) {
40             this.prr = prr;
41         }
42     }
43     private JsonNode id;
44     private String method;
45     private List<Params> params;
46
47     @JsonIgnore
48     private String name;
49
50     @Override
51     public JsonNode getId() {
52         return id;
53     }
54
55     @Override
56     public void setId(JsonNode id) {
57         this.id = id;
58     }
59
60     @Override
61     public String getMethod() {
62         return method;
63     }
64
65     @Override
66     public void setMethod(String method) {
67         this.method = method;
68     }
69
70     public List<Params> getParams() {
71         return this.params;
72     }
73
74     public void setParams(List<Params> params) {
75         this.params = params;
76     }
77
78     @Override
79     public String getName() {
80         return this.name;
81     }
82
83     @Override
84     public void setName(String name) {
85         this.name = name;
86     }
87
88     public EndpointDeclareRequest(String name) {
89         this.name = name;
90     }
91
92     public EndpointDeclareRequest() {
93         this.name = DECLARE_MESSAGE;
94         this.method = DECLARE_MESSAGE;
95     }
96
97     /**
98      * Minimal check on validity of message
99      * @return true if message has passed validity check
100      */
101     @JsonIgnore
102     @Override
103     public boolean valid() {
104         if (params == null)
105             return false;
106         if (params.get(0) == null)
107             return false;
108
109         return true;
110     }
111 }