[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / dmaap-bc / src / main / java / org / onap / dmaap / dbcapi / aaf / AafRole.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.dmaap.dbcapi.aaf;
22
23 import java.util.Objects;
24
25 public class AafRole extends AafObject  {
26
27         private String  namespace;
28         private String  role;
29         
30         public AafRole(String ns,  String role) {
31                 super();
32                 this.namespace = ns;
33                 this.role = role;
34         }
35         public void setNamespace( String ns ) {
36                 this.namespace = ns;
37         }
38         public String getNamespace() {
39                 return namespace;
40         }
41         public void setRole(String role) {
42                 this.role = role;
43         }
44         public String getRole() {
45                 return role;
46         }
47         public String getFullyQualifiedRole() {
48                 return namespace + "." + role;
49         }
50
51         public String toJSON() {
52
53                 String postJSON = String.format(" { \"name\": \"%s.%s\"}", 
54                                 this.getNamespace(), 
55                                 this.getRole() );
56                 logger.info( "returning JSON: " + postJSON);
57                         
58                 return postJSON;
59         }
60
61         @Override
62         public boolean equals(Object o) {
63                 if (this == o) return true;
64                 if (o == null || getClass() != o.getClass()) return false;
65                 AafRole aafRole = (AafRole) o;
66                 return Objects.equals(namespace, aafRole.namespace) &&
67                                 Objects.equals(role, aafRole.role);
68         }
69
70         @Override
71         public int hashCode() {
72                 return Objects.hash(namespace, role);
73         }
74 }