2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 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.appc;
23 import com.google.gson.annotations.SerializedName;
25 import java.io.Serializable;
26 import java.time.Instant;
27 import java.util.ArrayList;
28 import java.util.Collection;
30 import java.util.UUID;
32 public class CommonHeader implements Serializable {
33 private static final long serialVersionUID = -3581658269910980336L;
35 @SerializedName("TimeStamp")
36 private Instant timeStamp = Instant.now();
38 @SerializedName("APIver")
39 private String apiVer = "1.01";
41 @SerializedName("OriginatorID")
42 private String originatorId;
44 @SerializedName("RequestID")
45 private UUID requestId;
47 @SerializedName("SubRequestID")
48 private String subRequestId;
50 @SerializedName("RequestTrack")
51 private Collection<String> requestTrack = new ArrayList<>();
53 @SerializedName("Flags")
54 private Collection<Map<String, String>> flags = new ArrayList<>();
56 public CommonHeader() {}
59 * Construct an instance from an existing instance.
61 * @param commonHeader the existing instance
63 public CommonHeader(CommonHeader commonHeader) {
64 this.originatorId = commonHeader.originatorId;
65 this.requestId = commonHeader.requestId;
66 this.subRequestId = commonHeader.subRequestId;
67 if (commonHeader.requestTrack != null) {
68 this.requestTrack.addAll(commonHeader.requestTrack);
70 if (commonHeader.flags != null) {
71 this.flags.addAll(commonHeader.flags);
75 public Instant getTimeStamp() {
79 public void setTimeStamp(Instant timeStamp) {
80 this.timeStamp = timeStamp;
83 public String getApiVer() {
87 public void setApiVer(String apiVer) {
91 public String getOriginatorId() {
95 public void setOriginatorId(String originatorId) {
96 this.originatorId = originatorId;
99 public UUID getRequestId() {
103 public void setRequestId(UUID requestId) {
104 this.requestId = requestId;
107 public String getSubRequestId() {
111 public void setSubRequestId(String subRequestId) {
112 this.subRequestId = subRequestId;
115 public Collection<String> getRequestTrack() {
119 public void setRequestTrack(Collection<String> requestTrack) {
120 this.requestTrack = requestTrack;
123 public Collection<Map<String, String>> getFlags() {
127 public void setFlags(Collection<Map<String, String>> flags) {
132 public String toString() {
133 return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorId=" + originatorId
134 + ", RequestId=" + requestId + ", SubrequestId=" + subRequestId + ", RequestTrack=" + requestTrack
135 + ", Flags=" + flags + "]";
139 public int hashCode() {
140 final int prime = 31;
142 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
143 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
144 result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
145 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
146 result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
147 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
148 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
153 public boolean equals(Object obj) {
160 if (getClass() != obj.getClass()) {
163 CommonHeader other = (CommonHeader) obj;
164 if (apiVer == null) {
165 if (other.apiVer != null) {
168 } else if (!apiVer.equals(other.apiVer)) {
172 if (other.flags != null) {
175 } else if (!flags.equals(other.flags)) {
178 if (originatorId == null) {
179 if (other.originatorId != null) {
182 } else if (!originatorId.equals(other.originatorId)) {
185 if (requestId == null) {
186 if (other.requestId != null) {
189 } else if (!requestId.equals(other.requestId)) {
192 if (requestTrack == null) {
193 if (other.requestTrack != null) {
196 } else if (!requestTrack.equals(other.requestTrack)) {
199 if (subRequestId == null) {
200 if (other.subRequestId != null) {
203 } else if (!subRequestId.equals(other.subRequestId)) {
206 if (timeStamp == null) {
207 if (other.timeStamp != null) {
210 } else if (!timeStamp.equals(other.timeStamp)) {