[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / dmaap-bc / src / main / java / org / onap / dmaap / dbcapi / aaf / DmaapPerm.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
26 public class DmaapPerm extends AafObject {
27
28     private String permission;
29     private String ptype;
30     private String action;
31
32     public DmaapPerm(String permission, String ptype, String action) {
33         super();
34         this.permission = permission;
35         this.ptype = ptype;
36         this.action = action;
37     }
38
39     public String getPermission() {
40         return permission;
41     }
42
43     public void setPermission(String permission) {
44         this.permission = permission;
45     }
46
47     public String getPtype() {
48         return ptype;
49     }
50
51     public void setPtype(String ptype) {
52         this.ptype = ptype;
53     }
54
55     public String getAction() {
56         return action;
57     }
58
59     public void setAction(String action) {
60         this.action = action;
61     }
62
63     public String toJSON() {
64
65         String postJSON = String.format(" { \"type\": \"%s\", \"instance\": \"%s\", \"action\": \"%s\"}",
66                 this.getPermission(),
67                 this.getPtype(),
68                 this.getAction());
69         logger.info("returning JSON: " + postJSON);
70
71         return postJSON;
72     }
73
74
75     @Override
76     public boolean equals(Object o) {
77         if (this == o) return true;
78         if (o == null || getClass() != o.getClass()) return false;
79         DmaapPerm dmaapPerm = (DmaapPerm) o;
80         return Objects.equals(permission, dmaapPerm.permission) &&
81                 Objects.equals(ptype, dmaapPerm.ptype) &&
82                 Objects.equals(action, dmaapPerm.action);
83     }
84
85     @Override
86     public int hashCode() {
87         return Objects.hash(permission, ptype, action);
88     }
89 }