2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.appclcm;
23 import com.google.gson.annotations.SerializedName;
25 import java.io.Serializable;
26 import java.time.Instant;
27 import java.util.HashMap;
29 import java.util.UUID;
31 public class LcmCommonHeader implements Serializable {
33 private static final long serialVersionUID = 6581963539127062114L;
35 @SerializedName(value = "timestamp")
36 private Instant timeStamp = Instant.now();
38 @SerializedName(value = "api-ver")
39 private String apiVer = "2.00";
41 @SerializedName(value = "originator-id")
42 private String originatorId;
44 @SerializedName(value = "request-id")
45 private UUID requestId;
47 @SerializedName(value = "sub-request-id")
48 private String subRequestId;
50 @SerializedName(value = "flags")
51 private Map<String, String> flags = new HashMap<>();
53 public LcmCommonHeader() {
58 * Used to copy a common header.
60 * @param commonHeader a header that is defined by the lcm api guide that contains information
61 * about the request (requestId, flags, etc.)
63 public LcmCommonHeader(LcmCommonHeader commonHeader) {
64 this.originatorId = commonHeader.originatorId;
65 this.requestId = commonHeader.requestId;
66 this.subRequestId = commonHeader.subRequestId;
67 if (commonHeader.flags != null) {
68 this.flags.putAll(commonHeader.flags);
75 * @return the timeStamp
77 public Instant getTimeStamp() {
84 * @param timeStamp the timeStamp to set
86 public void setTimeStamp(Instant timeStamp) {
87 this.timeStamp = timeStamp;
91 * Get the API version.
95 public String getApiVer() {
100 * Set the API version.
102 * @param apiVer the apiVer to set
104 public void setApiVer(String apiVer) {
105 this.apiVer = apiVer;
109 * Get the originator Id.
111 * @return the originatorId
113 public String getOriginatorId() {
118 * Set the originator Id.
120 * @param originatorId the originatorId to set
122 public void setOriginatorId(String originatorId) {
123 this.originatorId = originatorId;
127 * Get the request Id.
129 * @return the requestId
131 public UUID getRequestId() {
136 * Set the request Id.
138 * @param requestId the requestId to set
140 public void setRequestId(UUID requestId) {
141 this.requestId = requestId;
145 * Get the sub request Id.
147 * @return the subRequestId
149 public String getSubRequestId() {
154 * Set the sub request Id.
156 * @param subRequestId the subRequestId to set
158 public void setSubRequestId(String subRequestId) {
159 this.subRequestId = subRequestId;
167 public Map<String, String> getFlags() {
174 * @param flags the flags to set
176 public void setFlags(Map<String, String> flags) {
181 public String toString() {
182 return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer + ", originatorId=" + originatorId
183 + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", flags=" + flags + "]";
187 public int hashCode() {
188 final int prime = 31;
190 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
191 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
192 result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
193 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
194 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
195 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
200 public boolean equals(Object obj) {
207 if (getClass() != obj.getClass()) {
210 LcmCommonHeader other = (LcmCommonHeader) obj;
211 if (apiVer == null) {
212 if (other.apiVer != null) {
215 } else if (!apiVer.equals(other.apiVer)) {
219 if (other.flags != null) {
222 } else if (!flags.equals(other.flags)) {
225 if (originatorId == null) {
226 if (other.originatorId != null) {
229 } else if (!originatorId.equals(other.originatorId)) {
232 if (requestId == null) {
233 if (other.requestId != null) {
236 } else if (!requestId.equals(other.requestId)) {
239 if (subRequestId == null) {
240 if (other.subRequestId != null) {
243 } else if (!subRequestId.equals(other.subRequestId)) {
246 if (timeStamp == null) {
247 if (other.timeStamp != null) {
250 } else if (!timeStamp.equals(other.timeStamp)) {