AafTopicSetupService implementation
[dmaap/dbcapi.git] / 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 org.apache.log4j.Logger;
24
25 import java.util.Objects;
26
27
28 public class AafRole extends AafObject  {
29         static final Logger logger = Logger.getLogger(AafRole.class);
30         
31         private String  namespace;
32         private String  role;
33         
34         public AafRole(String ns,  String role) {
35                 super();
36                 this.namespace = ns;
37                 this.role = role;
38         }
39         public void setNamespace( String ns ) {
40                 this.namespace = ns;
41         }
42         public String getNamespace() {
43                 return namespace;
44         }
45         public void setRole(String role) {
46                 this.role = role;
47         }
48         public String getRole() {
49                 return role;
50         }
51         public String getFullyQualifiedRole() {
52                 return namespace + "." + role;
53         }
54
55         public String toJSON() {
56
57                 String postJSON = String.format(" { \"name\": \"%s.%s\"}", 
58                                 this.getNamespace(), 
59                                 this.getRole() );
60                 logger.info( "returning JSON: " + postJSON);
61                         
62                 return postJSON;
63         }
64
65         @Override
66         public boolean equals(Object o) {
67                 if (this == o) return true;
68                 if (o == null || getClass() != o.getClass()) return false;
69                 AafRole aafRole = (AafRole) o;
70                 return Objects.equals(namespace, aafRole.namespace) &&
71                                 Objects.equals(role, aafRole.role);
72         }
73
74         @Override
75         public int hashCode() {
76                 return Objects.hash(namespace, role);
77         }
78 }