Separating renderers into features.
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / lib / messages / PolicyResolveRequest.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 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
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 PolicyResolveRequest extends RpcMessage {
25
26     public static final String RESOLVE_MESSAGE = "policy_resolve";
27
28     static public class Params {
29         private String subject;
30         private Uri policy_uri;
31         private PolicyIdentity policy_ident;
32         private String data;
33         private int prr;
34
35         public String getSubject() {
36             return subject;
37         }
38         public void setSubject(String subject) {
39             this.subject = subject;
40         }
41         public Uri getPolicy_uri() {
42             return policy_uri;
43         }
44         public void setPolicy_uri(Uri policy_uri) {
45             this.policy_uri = policy_uri;
46         }
47         public PolicyIdentity getPolicy_ident() {
48             return policy_ident;
49         }
50         public void setPolicy_ident(PolicyIdentity policy_ident) {
51             this.policy_ident = policy_ident;
52         }
53         public String getData() {
54             return data;
55         }
56         public void setData(String data) {
57             this.data = data;
58         }
59         public int getPrr() {
60             return prr;
61         }
62         public void setPrr(int prr) {
63             this.prr = prr;
64         }
65     }
66
67     private JsonNode id;
68     private String method;
69     private List<Params> params;
70
71     @JsonIgnore
72     private String name;
73
74     @Override
75     public JsonNode getId() {
76         return id;
77     }
78
79     @Override
80     public void setId(JsonNode id) {
81         this.id = id;
82     }
83
84     @Override
85     public String getMethod() {
86         return method;
87     }
88
89     @Override
90     public void setMethod(String method) {
91         this.method = method;
92     }
93
94     public List<Params> getParams() {
95         return this.params;
96     }
97
98     public void setParams(List<Params> params) {
99         this.params = params;
100     }
101
102     @Override
103     public String getName() {
104         return this.name;
105     }
106
107     @Override
108     public void setName(String name) {
109         this.name = name;
110     }
111
112     public PolicyResolveRequest(String name) {
113         this.name = name;
114     }
115
116     public PolicyResolveRequest() {
117         this.name = RESOLVE_MESSAGE;
118         this.method = RESOLVE_MESSAGE;
119     }
120
121     /**
122      * Minimal check on validity of message
123      * @return true if message has passed validity check
124      */
125     @JsonIgnore
126     @Override
127     public boolean valid() {
128         if (params == null)
129             return false;
130         if (params.get(0) == null)
131             return false;
132         return true;
133     }
134 }