2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Wipro Limited 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.sdnr;
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 PciCommonHeader implements Serializable {
33 private static final long serialVersionUID = 5435363539127062114L;
35 @SerializedName(value = "TimeStamp")
36 private Instant timeStamp = Instant.now();
38 @SerializedName(value = "APIVer")
39 private String apiVer = "1.0";
41 @SerializedName(value = "RequestID")
42 private UUID requestId;
44 @SerializedName(value = "SubRequestID")
45 private String subRequestId;
47 @SerializedName(value = "RequestTrack")
48 private Map<String, String> requestTrack = new HashMap<>();
50 @SerializedName(value = "Flags")
51 private Map<String, String> flags = new HashMap<>();
53 public PciCommonHeader() {
58 * Used to copy a pci common header.
60 * @param commonHeader a header that is defined by the Pci api guide that contains information
61 * about the request (requestId, flags, etc.)
63 public PciCommonHeader(PciCommonHeader commonHeader) {
64 this.timeStamp = commonHeader.timeStamp;
65 this.requestId = commonHeader.requestId;
66 this.subRequestId = commonHeader.subRequestId;
67 if (commonHeader.requestTrack != null) {
68 this.requestTrack.putAll(commonHeader.requestTrack);
70 if (commonHeader.flags != null) {
71 this.flags.putAll(commonHeader.flags);
78 * @return the timeStamp
80 public Instant getTimeStamp() {
88 * the timeStamp to set
90 public void setTimeStamp(Instant timeStamp) {
91 this.timeStamp = timeStamp;
95 * Get the API version.
99 public String getApiVer() {
104 * Set the API version.
109 public void setApiVer(String apiVer) {
110 this.apiVer = apiVer;
114 * Get the request Id.
116 * @return the requestId
118 public UUID getRequestId() {
123 * Set the request Id.
126 * the requestId to set
128 public void setRequestId(UUID requestId) {
129 this.requestId = requestId;
133 * Get the sub request Id.
135 * @return the subRequestId
137 public String getSubRequestId() {
142 * Set the sub request Id.
144 * @param subRequestId
145 * the subRequestId to set
147 public void setSubRequestId(String subRequestId) {
148 this.subRequestId = subRequestId;
151 * Set the request track.
153 * @param requestTrack
154 * the requestTrack to set
156 public void setRequestTrack(Map<String, String> requestTrack) {
157 this.requestTrack = requestTrack;
160 * Get the request track.
162 * @return the requestTrack
164 public Map<String, String> getRequestTrack() {
173 public Map<String, String> getFlags() {
183 public void setFlags(Map<String, String> flags) {
188 public String toString() {
189 return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer
190 + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack
191 + ", flags=" + flags + "]";
195 public int hashCode() {
196 final int prime = 31;
198 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
199 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
200 result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
201 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
202 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
203 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
208 public boolean equals(Object obj) {
215 if (getClass() != obj.getClass()) {
218 PciCommonHeader other = (PciCommonHeader) obj;
219 if (apiVer == null) {
220 if (other.apiVer != null) {
223 } else if (!apiVer.equals(other.apiVer)) {
227 if (other.flags != null) {
230 } else if (!flags.equals(other.flags)) {
233 if (requestTrack == null) {
234 if (other.requestTrack != null) {
237 } else if (!requestTrack.equals(other.requestTrack)) {
240 if (requestId == null) {
241 if (other.requestId != null) {
244 } else if (!requestId.equals(other.requestId)) {
247 if (subRequestId == null) {
248 if (other.subRequestId != null) {
251 } else if (!subRequestId.equals(other.subRequestId)) {
254 if (timeStamp == null) {
255 if (other.timeStamp != null) {
258 } else if (!timeStamp.equals(other.timeStamp)) {