Separating renderers into features.
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / lib / messages / ManagedObject.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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
15
16 import com.fasterxml.jackson.databind.JsonNode;
17 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
18 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
19
20 @JsonSerialize
21 @JsonDeserialize
22 public class ManagedObject {
23
24         public static class Property {
25         private String name;
26         private JsonNode data;
27         public String getName() {
28             return name;
29         }
30         public void setName(String name) {
31             this.name = name;
32         }
33         public JsonNode getData() {
34             return data;
35         }
36         public void setData(JsonNode data) {
37             this.data = data;
38         }
39                 @Override
40                 public int hashCode() {
41                         final int prime = 31;
42                         int result = 1;
43                         result = prime * result + ((data == null) ? 0 : data.hashCode());
44                         result = prime * result + ((name == null) ? 0 : name.hashCode());
45                         return result;
46                 }
47                 @Override
48                 public boolean equals(Object obj) {
49                         if (this == obj)
50                                 return true;
51                         if (obj == null)
52                                 return false;
53                         if (getClass() != obj.getClass())
54                                 return false;
55                         Property other = (Property) obj;
56                         if (data == null) {
57                                 if (other.data != null)
58                                         return false;
59                         } else if (!data.asText().equals(other.getData().asText()))
60                                 return false;
61                         if (name == null) {
62                                 if (other.name != null)
63                                         return false;
64                         } else if (!name.equals(other.name))
65                                 return false;
66                         return true;
67                 }
68
69     }
70
71     private String subject;
72     private Uri uri;
73     private List<Property> properties;
74     private String parent_subject;
75     private Uri parent_uri;
76     private String parent_relation;
77     private List<Uri> children;
78
79         public String getSubject() {
80                 return subject;
81         }
82         public void setSubject(String subject) {
83                 this.subject = subject;
84         }
85         public Uri getUri() {
86                 return uri;
87         }
88         public void setUri(Uri uri) {
89                 this.uri = uri;
90         }
91         public List<Property> getProperties() {
92                 return properties;
93         }
94         public void setProperties(List<Property> properties) {
95                 this.properties = properties;
96         }
97         public String getParent_subject() {
98                 return parent_subject;
99         }
100         public void setParent_subject(String parent_subject) {
101                 this.parent_subject = parent_subject;
102         }
103         public Uri getParent_uri() {
104                 return parent_uri;
105         }
106         public void setParent_uri(Uri parent_uri) {
107                 this.parent_uri = parent_uri;
108         }
109         public String getParent_relation() {
110                 return parent_relation;
111         }
112         public void setParent_relation(String parent_relation) {
113                 this.parent_relation = parent_relation;
114         }
115         public List<Uri> getChildren() {
116                 return children;
117         }
118         public void setChildren(List<Uri> children) {
119                 this.children = children;
120         }
121
122     @Override
123         public int hashCode() {
124                 final int prime = 31;
125                 int result = 1;
126                 result = prime * result
127                                 + ((children == null) ? 0 : children.hashCode());
128                 result = prime * result
129                                 + ((parent_relation == null) ? 0 : parent_relation.hashCode());
130                 result = prime * result
131                                 + ((parent_subject == null) ? 0 : parent_subject.hashCode());
132                 result = prime * result
133                                 + ((parent_uri == null) ? 0 : parent_uri.hashCode());
134                 result = prime * result
135                                 + ((properties == null) ? 0 : properties.hashCode());
136                 result = prime * result + ((subject == null) ? 0 : subject.hashCode());
137                 result = prime * result + ((uri == null) ? 0 : uri.hashCode());
138                 return result;
139         }
140
141         @Override
142         public boolean equals(Object obj) {
143                 if (this == obj)
144                         return true;
145                 if (obj == null)
146                         return false;
147                 if (getClass() != obj.getClass())
148                         return false;
149                 ManagedObject other = (ManagedObject) obj;
150                 if (children == null) {
151                         if (other.children != null)
152                                 return false;
153                 } else if (!children.equals(other.children))
154                         return false;
155                 if (parent_relation == null) {
156                         if (other.parent_relation != null)
157                                 return false;
158                 } else if (!parent_relation.equals(other.parent_relation))
159                         return false;
160                 if (parent_subject == null) {
161                         if (other.parent_subject != null)
162                                 return false;
163                 } else if (!parent_subject.equals(other.parent_subject))
164                         return false;
165                 if (parent_uri == null) {
166                         if (other.parent_uri != null)
167                                 return false;
168                 } else if (!parent_uri.equals(other.parent_uri))
169                         return false;
170                 if (properties == null) {
171                         if (other.properties != null)
172                                 return false;
173                 } else if (!properties.equals(other.properties))
174                         return false;
175                 if (subject == null) {
176                         if (other.subject != null)
177                                 return false;
178                 } else if (!subject.equals(other.subject))
179                         return false;
180                 if (uri == null) {
181                         if (other.uri != null)
182                                 return false;
183                 } else if (!uri.equals(other.uri))
184                         return false;
185                 return true;
186         }
187 }