2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.appclcm;
24 import com.google.gson.annotations.SerializedName;
26 import java.io.Serializable;
27 import java.time.Instant;
28 import java.util.HashMap;
30 import java.util.UUID;
32 public class LcmCommonHeader implements Serializable {
34 private static final long serialVersionUID = 6581963539127062114L;
36 @SerializedName(value = "timestamp")
37 private Instant timeStamp = Instant.now();
39 @SerializedName(value = "api-ver")
40 private String apiVer = "2.00";
42 @SerializedName(value = "originator-id")
43 private String originatorId;
45 @SerializedName(value = "request-id")
46 private UUID requestId;
48 @SerializedName(value = "sub-request-id")
49 private String subRequestId;
51 @SerializedName(value = "flags")
52 private Map<String, String> flags = new HashMap<>();
54 public LcmCommonHeader() {
59 * Used to copy a common header.
61 * @param commonHeader a header that is defined by the lcm api guide that contains information
62 * about the request (requestId, flags, etc.)
64 public LcmCommonHeader(LcmCommonHeader commonHeader) {
65 this.originatorId = commonHeader.originatorId;
66 this.requestId = commonHeader.requestId;
67 this.subRequestId = commonHeader.subRequestId;
68 if (commonHeader.flags != null) {
69 this.flags.putAll(commonHeader.flags);
76 * @return the timeStamp
78 public Instant getTimeStamp() {
85 * @param timeStamp the timeStamp to set
87 public void setTimeStamp(Instant timeStamp) {
88 this.timeStamp = timeStamp;
92 * Get the API version.
96 public String getApiVer() {
101 * Set the API version.
103 * @param apiVer the apiVer to set
105 public void setApiVer(String apiVer) {
106 this.apiVer = apiVer;
110 * Get the originator Id.
112 * @return the originatorId
114 public String getOriginatorId() {
119 * Set the originator Id.
121 * @param originatorId the originatorId to set
123 public void setOriginatorId(String originatorId) {
124 this.originatorId = originatorId;
128 * Get the request Id.
130 * @return the requestId
132 public UUID getRequestId() {
137 * Set the request Id.
139 * @param requestId the requestId to set
141 public void setRequestId(UUID requestId) {
142 this.requestId = requestId;
146 * Get the sub request Id.
148 * @return the subRequestId
150 public String getSubRequestId() {
155 * Set the sub request Id.
157 * @param subRequestId the subRequestId to set
159 public void setSubRequestId(String subRequestId) {
160 this.subRequestId = subRequestId;
168 public Map<String, String> getFlags() {
175 * @param flags the flags to set
177 public void setFlags(Map<String, String> flags) {
182 public String toString() {
183 return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer + ", originatorId=" + originatorId
184 + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", flags=" + flags + "]";
188 public int hashCode() {
189 final int prime = 31;
191 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
192 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
193 result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
194 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
195 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
196 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
201 public boolean equals(Object obj) {
208 if (getClass() != obj.getClass()) {
211 LcmCommonHeader other = (LcmCommonHeader) obj;
212 if (apiVer == null) {
213 if (other.apiVer != null) {
216 } else if (!apiVer.equals(other.apiVer)) {
220 if (other.flags != null) {
223 } else if (!flags.equals(other.flags)) {
226 if (originatorId == null) {
227 if (other.originatorId != null) {
230 } else if (!originatorId.equals(other.originatorId)) {
233 if (requestId == null) {
234 if (other.requestId != null) {
237 } else if (!requestId.equals(other.requestId)) {
240 if (subRequestId == null) {
241 if (other.subRequestId != null) {
244 } else if (!subRequestId.equals(other.subRequestId)) {
247 if (timeStamp == null) {
248 if (other.timeStamp != null) {
251 } else if (!timeStamp.equals(other.timeStamp)) {