2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.sdnr;
25 import com.google.gson.annotations.SerializedName;
27 import java.io.Serializable;
28 import java.time.Instant;
29 import java.util.HashMap;
31 import java.util.UUID;
33 public class PciCommonHeader implements Serializable {
35 private static final long serialVersionUID = 5435363539127062114L;
37 @SerializedName(value = "TimeStamp")
38 private Instant timeStamp = Instant.now();
40 @SerializedName(value = "APIVer")
41 private String apiVer = "1.0";
43 @SerializedName(value = "RequestID")
44 private UUID requestId;
46 @SerializedName(value = "SubRequestID")
47 private String subRequestId;
49 @SerializedName(value = "RequestTrack")
50 private Map<String, String> requestTrack = new HashMap<>();
52 @SerializedName(value = "Flags")
53 private Map<String, String> flags = new HashMap<>();
55 public PciCommonHeader() {
60 * Used to copy a pci common header.
62 * @param commonHeader a header that is defined by the Pci api guide that contains information
63 * about the request (requestId, flags, etc.)
65 public PciCommonHeader(PciCommonHeader commonHeader) {
66 this.timeStamp = commonHeader.timeStamp;
67 this.requestId = commonHeader.requestId;
68 this.subRequestId = commonHeader.subRequestId;
69 if (commonHeader.requestTrack != null) {
70 this.requestTrack.putAll(commonHeader.requestTrack);
72 if (commonHeader.flags != null) {
73 this.flags.putAll(commonHeader.flags);
80 * @return the timeStamp
82 public Instant getTimeStamp() {
90 * the timeStamp to set
92 public void setTimeStamp(Instant timeStamp) {
93 this.timeStamp = timeStamp;
97 * Get the API version.
101 public String getApiVer() {
106 * Set the API version.
111 public void setApiVer(String apiVer) {
112 this.apiVer = apiVer;
116 * Get the request Id.
118 * @return the requestId
120 public UUID getRequestId() {
125 * Set the request Id.
128 * the requestId to set
130 public void setRequestId(UUID requestId) {
131 this.requestId = requestId;
135 * Get the sub request Id.
137 * @return the subRequestId
139 public String getSubRequestId() {
144 * Set the sub request Id.
146 * @param subRequestId
147 * the subRequestId to set
149 public void setSubRequestId(String subRequestId) {
150 this.subRequestId = subRequestId;
154 * Set the request track.
156 * @param requestTrack
157 * the requestTrack to set
159 public void setRequestTrack(Map<String, String> requestTrack) {
160 this.requestTrack = requestTrack;
164 * Get the request track.
166 * @return the requestTrack
168 public Map<String, String> getRequestTrack() {
177 public Map<String, String> getFlags() {
187 public void setFlags(Map<String, String> flags) {
192 public String toString() {
193 return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer
194 + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack
195 + ", flags=" + flags + "]";
199 public int hashCode() {
200 final int prime = 31;
202 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
203 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
204 result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
205 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
206 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
207 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
212 public boolean equals(Object obj) {
219 if (getClass() != obj.getClass()) {
222 PciCommonHeader other = (PciCommonHeader) obj;
223 if (apiVer == null) {
224 if (other.apiVer != null) {
227 } else if (!apiVer.equals(other.apiVer)) {
231 if (other.flags != null) {
234 } else if (!flags.equals(other.flags)) {
237 if (requestTrack == null) {
238 if (other.requestTrack != null) {
241 } else if (!requestTrack.equals(other.requestTrack)) {
244 if (requestId == null) {
245 if (other.requestId != null) {
248 } else if (!requestId.equals(other.requestId)) {
251 if (subRequestId == null) {
252 if (other.subRequestId != null) {
255 } else if (!subRequestId.equals(other.subRequestId)) {
258 if (timeStamp == null) {
259 if (other.timeStamp != null) {
262 } else if (!timeStamp.equals(other.timeStamp)) {