migrate model-impl from drools-applications
[policy/models.git] / models-interactions / model-impl / appc / src / main / java / org / onap / policy / appc / Request.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appc
4  * ================================================================================
5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.appc;
23
24 import com.google.gson.annotations.SerializedName;
25
26 import java.io.Serializable;
27 import java.util.HashMap;
28 import java.util.Map;
29
30 public class Request implements Serializable {
31     private static final long serialVersionUID = -3912323643990646431L;
32
33     @SerializedName("CommonHeader")
34     private CommonHeader commonHeader;
35
36     @SerializedName("Action")
37     private String action;
38
39     @SerializedName("TargetID")
40     private String targetId;
41
42     @SerializedName("ObjectID")
43     private String objectId;
44
45     @SerializedName("Payload")
46     private HashMap<String, Object> payload = new HashMap<>();
47
48     public Request() {
49         // Initiate an empty Request instance
50     }
51
52     public CommonHeader getCommonHeader() {
53         return commonHeader;
54     }
55
56     public Map<String, Object> getPayload() {
57         return payload;
58     }
59
60     public String getAction() {
61         return action;
62     }
63
64     public void setAction(String action) {
65         this.action = action;
66     }
67
68     public String getTargetId() {
69         return targetId;
70     }
71
72     public void setTargetId(String targetId) {
73         this.targetId = targetId;
74     }
75
76     public String getObjectId() {
77         return objectId;
78     }
79
80     public void setObjectId(String objectId) {
81         this.objectId = objectId;
82     }
83
84     public void setCommonHeader(CommonHeader commonHeader) {
85         this.commonHeader = commonHeader;
86     }
87
88     public void setPayload(Map<String, Object> payload) {
89         this.payload = new HashMap<>(payload);
90     }
91
92     @Override
93     public int hashCode() {
94         final int prime = 31;
95         int result = 1;
96         result = prime * result + ((action == null) ? 0 : action.hashCode());
97         result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
98         result = prime * result + ((objectId == null) ? 0 : objectId.hashCode());
99         result = prime * result + ((payload == null) ? 0 : payload.hashCode());
100         result = prime * result + ((targetId == null) ? 0 : targetId.hashCode());
101         return result;
102     }
103
104     @Override
105     public boolean equals(Object obj) {
106         if (this == obj) {
107             return true;
108         }
109         if (obj == null) {
110             return false;
111         }
112         if (getClass() != obj.getClass()) {
113             return false;
114         }
115
116         Request other = (Request) obj;
117         if (action == null) {
118             if (other.action != null) {
119                 return false;
120             }
121         } else if (!action.equals(other.action)) {
122             return false;
123         }
124
125         if (commonHeader == null) {
126             if (other.commonHeader != null) {
127                 return false;
128             }
129         } else if (!commonHeader.equals(other.commonHeader)) {
130             return false;
131         }
132
133         if (objectId == null) {
134             if (other.objectId != null) {
135                 return false;
136             }
137         } else if (!objectId.equals(other.objectId)) {
138             return false;
139         }
140
141         if (payload == null) {
142             if (other.payload != null) {
143                 return false;
144             }
145         } else if (!payload.equals(other.payload)) {
146             return false;
147         }
148
149         if (targetId == null) {
150             if (other.targetId != null) {
151                 return false;
152             }
153         } else if (!targetId.equals(other.targetId)) {
154             return false;
155         }
156
157         return true;
158     }
159
160     @Override
161     public String toString() {
162         return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetId=" + targetId + ", ObjectId="
163                 + objectId + ", Payload=" + payload + "]";
164     }
165
166 }