Use lombok annotations for objects in models-interaction/models-impl module
[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 import lombok.Getter;
30 import lombok.Setter;
31
32 @Getter
33 @Setter
34 public class Request implements Serializable {
35     private static final long serialVersionUID = -3912323643990646431L;
36
37     @SerializedName("CommonHeader")
38     private CommonHeader commonHeader;
39
40     @SerializedName("Action")
41     private String action;
42
43     @SerializedName("TargetID")
44     private String targetId;
45
46     @SerializedName("ObjectID")
47     private String objectId;
48
49     @SerializedName("Payload")
50     private Map<String, Object> payload = new HashMap<>();
51
52     public Request() {
53         // Initiate an empty Request instance
54     }
55
56     @Override
57     public int hashCode() {
58         final int prime = 31;
59         int result = 1;
60         result = prime * result + ((action == null) ? 0 : action.hashCode());
61         result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
62         result = prime * result + ((objectId == null) ? 0 : objectId.hashCode());
63         result = prime * result + ((payload == null) ? 0 : payload.hashCode());
64         result = prime * result + ((targetId == null) ? 0 : targetId.hashCode());
65         return result;
66     }
67
68     @Override
69     public boolean equals(Object obj) {
70         if (this == obj) {
71             return true;
72         }
73         if (obj == null) {
74             return false;
75         }
76         if (getClass() != obj.getClass()) {
77             return false;
78         }
79
80         Request other = (Request) obj;
81         if (action == null) {
82             if (other.action != null) {
83                 return false;
84             }
85         } else if (!action.equals(other.action)) {
86             return false;
87         }
88
89         if (commonHeader == null) {
90             if (other.commonHeader != null) {
91                 return false;
92             }
93         } else if (!commonHeader.equals(other.commonHeader)) {
94             return false;
95         }
96
97         if (objectId == null) {
98             if (other.objectId != null) {
99                 return false;
100             }
101         } else if (!objectId.equals(other.objectId)) {
102             return false;
103         }
104
105         if (payload == null) {
106             if (other.payload != null) {
107                 return false;
108             }
109         } else if (!payload.equals(other.payload)) {
110             return false;
111         }
112
113         if (targetId == null) {
114             if (other.targetId != null) {
115                 return false;
116             }
117         } else if (!targetId.equals(other.targetId)) {
118             return false;
119         }
120
121         return true;
122     }
123
124     @Override
125     public String toString() {
126         return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetId=" + targetId + ", ObjectId="
127                 + objectId + ", Payload=" + payload + "]";
128     }
129
130 }