2 * ============LICENSE_START=======================================================
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
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 java.io.Serializable;
24 import java.time.Instant;
25 import java.util.HashMap;
27 import java.util.UUID;
29 import com.google.gson.annotations.SerializedName;
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="5.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.
61 * a header that is defined by the lcm api guide that contains
62 * information 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);
74 * @return the timeStamp
76 public Instant getTimeStamp() {
81 * @param timeStamp the timeStamp to set
83 public void setTimeStamp(Instant timeStamp) {
84 this.timeStamp = timeStamp;
90 public String getApiVer() {
95 * @param apiVer the apiVer to set
97 public void setApiVer(String apiVer) {
102 * @return the originatorId
104 public String getOriginatorId() {
109 * @param originatorId the originatorId to set
111 public void setOriginatorId(String originatorId) {
112 this.originatorId = originatorId;
116 * @return the requestId
118 public UUID getRequestId() {
123 * @param requestId the requestId to set
125 public void setRequestId(UUID requestId) {
126 this.requestId = requestId;
130 * @return the subRequestId
132 public String getSubRequestId() {
137 * @param subRequestId the subRequestId to set
139 public void setSubRequestId(String subRequestId) {
140 this.subRequestId = subRequestId;
146 public Map<String, String> getFlags() {
151 * @param flags the flags to set
153 public void setFlags(Map<String, String> flags) {
158 public String toString() {
159 return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer + ", originatorId=" + originatorId
160 + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", flags=" + flags + "]";
164 public int hashCode() {
165 final int prime = 31;
167 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
168 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
169 result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
170 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
171 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
172 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
177 public boolean equals(Object obj) {
184 if (getClass() != obj.getClass()) {
187 LCMCommonHeader other = (LCMCommonHeader) obj;
188 if (apiVer == null) {
189 if (other.apiVer != null) {
192 } else if (!apiVer.equals(other.apiVer)) {
196 if (other.flags != null) {
199 } else if (!flags.equals(other.flags)) {
202 if (originatorId == null) {
203 if (other.originatorId != null) {
206 } else if (!originatorId.equals(other.originatorId)) {
209 if (requestId == null) {
210 if (other.requestId != null) {
213 } else if (!requestId.equals(other.requestId)) {
216 if (subRequestId == null) {
217 if (other.subRequestId != null) {
220 } else if (!subRequestId.equals(other.subRequestId)) {
223 if (timeStamp == null) {
224 if (other.timeStamp != null) {
227 } else if (!timeStamp.equals(other.timeStamp)) {