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.appc;
24 import com.google.gson.annotations.SerializedName;
26 import java.io.Serializable;
27 import java.time.Instant;
28 import java.util.ArrayList;
29 import java.util.Collection;
31 import java.util.UUID;
33 public class CommonHeader implements Serializable {
34 private static final long serialVersionUID = -3581658269910980336L;
36 @SerializedName("TimeStamp")
37 private Instant timeStamp = Instant.now();
39 @SerializedName("APIver")
40 private String apiVer = "1.01";
42 @SerializedName("OriginatorID")
43 private String originatorId;
45 @SerializedName("RequestID")
46 private UUID requestId;
48 @SerializedName("SubRequestID")
49 private String subRequestId;
51 @SerializedName("RequestTrack")
52 private Collection<String> requestTrack = new ArrayList<>();
54 @SerializedName("Flags")
55 private Collection<Map<String, String>> flags = new ArrayList<>();
57 public CommonHeader() {}
60 * Construct an instance from an existing instance.
62 * @param commonHeader the existing instance
64 public CommonHeader(CommonHeader commonHeader) {
65 this.originatorId = commonHeader.originatorId;
66 this.requestId = commonHeader.requestId;
67 this.subRequestId = commonHeader.subRequestId;
68 if (commonHeader.requestTrack != null) {
69 this.requestTrack.addAll(commonHeader.requestTrack);
71 if (commonHeader.flags != null) {
72 this.flags.addAll(commonHeader.flags);
76 public Instant getTimeStamp() {
80 public void setTimeStamp(Instant timeStamp) {
81 this.timeStamp = timeStamp;
84 public String getApiVer() {
88 public void setApiVer(String apiVer) {
92 public String getOriginatorId() {
96 public void setOriginatorId(String originatorId) {
97 this.originatorId = originatorId;
100 public UUID getRequestId() {
104 public void setRequestId(UUID requestId) {
105 this.requestId = requestId;
108 public String getSubRequestId() {
112 public void setSubRequestId(String subRequestId) {
113 this.subRequestId = subRequestId;
116 public Collection<String> getRequestTrack() {
120 public void setRequestTrack(Collection<String> requestTrack) {
121 this.requestTrack = requestTrack;
124 public Collection<Map<String, String>> getFlags() {
128 public void setFlags(Collection<Map<String, String>> flags) {
133 public String toString() {
134 return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorId=" + originatorId
135 + ", RequestId=" + requestId + ", SubrequestId=" + subRequestId + ", RequestTrack=" + requestTrack
136 + ", Flags=" + flags + "]";
140 public int hashCode() {
141 final int prime = 31;
143 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
144 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
145 result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
146 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
147 result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
148 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
149 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
154 public boolean equals(Object obj) {
161 if (getClass() != obj.getClass()) {
164 CommonHeader other = (CommonHeader) obj;
165 if (apiVer == null) {
166 if (other.apiVer != null) {
169 } else if (!apiVer.equals(other.apiVer)) {
173 if (other.flags != null) {
176 } else if (!flags.equals(other.flags)) {
179 if (originatorId == null) {
180 if (other.originatorId != null) {
183 } else if (!originatorId.equals(other.originatorId)) {
186 if (requestId == null) {
187 if (other.requestId != null) {
190 } else if (!requestId.equals(other.requestId)) {
193 if (requestTrack == null) {
194 if (other.requestTrack != null) {
197 } else if (!requestTrack.equals(other.requestTrack)) {
200 if (subRequestId == null) {
201 if (other.subRequestId != null) {
204 } else if (!subRequestId.equals(other.subRequestId)) {
207 if (timeStamp == null) {
208 if (other.timeStamp != null) {
211 } else if (!timeStamp.equals(other.timeStamp)) {