datarouter-prov code clean - remove tabs
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / FeedAuthorization.java
1 /*******************************************************************************\r
2  * ============LICENSE_START==================================================\r
3  * * org.onap.dmaap\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * ===========================================================================\r
7  * * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * * you may not use this file except in compliance with the License.\r
9  * * You may obtain a copy of the License at\r
10  * *\r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * *\r
13  *  * Unless required by applicable law or agreed to in writing, software\r
14  * * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * * See the License for the specific language governing permissions and\r
17  * * limitations under the License.\r
18  * * ============LICENSE_END====================================================\r
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 \r
24 \r
25 package org.onap.dmaap.datarouter.provisioning.beans;\r
26 \r
27 import java.util.HashSet;\r
28 import java.util.Set;\r
29 \r
30 import org.json.JSONArray;\r
31 import org.json.JSONObject;\r
32 \r
33 /**\r
34  * The representation of a Feed authorization.  This encapsulates the authorization information about a feed.\r
35  *\r
36  * @author Robert Eby\r
37  * @version $Id: FeedAuthorization.java,v 1.2 2013/06/20 14:11:05 eby Exp $\r
38  */\r
39 public class FeedAuthorization implements JSONable {\r
40     private String classification;\r
41     private Set<FeedEndpointID> endpoint_ids;\r
42     private Set<String> endpoint_addrs;\r
43 \r
44     public FeedAuthorization() {\r
45         this.classification = "";\r
46         this.endpoint_ids = new HashSet<FeedEndpointID>();\r
47         this.endpoint_addrs = new HashSet<String>();\r
48     }\r
49 \r
50     public String getClassification() {\r
51         return classification;\r
52     }\r
53 \r
54     public void setClassification(String classification) {\r
55         this.classification = classification;\r
56     }\r
57 \r
58     public Set<FeedEndpointID> getEndpoint_ids() {\r
59         return endpoint_ids;\r
60     }\r
61 \r
62     public void setEndpoint_ids(Set<FeedEndpointID> endpoint_ids) {\r
63         this.endpoint_ids = endpoint_ids;\r
64     }\r
65 \r
66     public Set<String> getEndpoint_addrs() {\r
67         return endpoint_addrs;\r
68     }\r
69 \r
70     public void setEndpoint_addrs(Set<String> endpoint_addrs) {\r
71         this.endpoint_addrs = endpoint_addrs;\r
72     }\r
73 \r
74     @Override\r
75     public JSONObject asJSONObject() {\r
76         JSONObject jo = new JSONObject();\r
77         jo.put("classification", classification);\r
78         JSONArray ja = new JSONArray();\r
79         for (FeedEndpointID eid : endpoint_ids) {\r
80             ja.put(eid.asJSONObject());\r
81         }\r
82         jo.put("endpoint_ids", ja);\r
83         ja = new JSONArray();\r
84         for (String t : endpoint_addrs) {\r
85             ja.put(t);\r
86         }\r
87         jo.put("endpoint_addrs", ja);\r
88         return jo;\r
89     }\r
90 \r
91     @Override\r
92     public boolean equals(Object obj) {\r
93         if (!(obj instanceof FeedAuthorization))\r
94             return false;\r
95         FeedAuthorization of = (FeedAuthorization) obj;\r
96         if (!classification.equals(of.classification))\r
97             return false;\r
98         if (!endpoint_ids.equals(of.endpoint_ids))\r
99             return false;\r
100         if (!endpoint_addrs.equals(of.endpoint_addrs))\r
101             return false;\r
102         return true;\r
103     }\r
104 }\r