2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Wipro Limited 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.sdnr;
24 import com.google.gson.annotations.SerializedName;
26 import java.io.Serializable;
27 import java.time.Instant;
28 import java.util.HashMap;
30 import java.util.UUID;
32 public class PciCommonHeader implements Serializable {
34 private static final long serialVersionUID = 5435363539127062114L;
36 @SerializedName(value = "TimeStamp")
37 private Instant timeStamp = Instant.now();
39 @SerializedName(value = "APIVer")
40 private String apiVer = "1.0";
42 @SerializedName(value = "RequestID")
43 private UUID requestId;
45 @SerializedName(value = "SubRequestID")
46 private String subRequestId;
48 @SerializedName(value = "RequestTrack")
49 private Map<String, String> requestTrack = new HashMap<>();
51 @SerializedName(value = "Flags")
52 private Map<String, String> flags = new HashMap<>();
54 public PciCommonHeader() {
59 * Used to copy a pci common header.
61 * @param commonHeader a header that is defined by the Pci api guide that contains information
62 * about the request (requestId, flags, etc.)
64 public PciCommonHeader(PciCommonHeader commonHeader) {
65 this.timeStamp = commonHeader.timeStamp;
66 this.requestId = commonHeader.requestId;
67 this.subRequestId = commonHeader.subRequestId;
68 if (commonHeader.requestTrack != null) {
69 this.requestTrack.putAll(commonHeader.requestTrack);
71 if (commonHeader.flags != null) {
72 this.flags.putAll(commonHeader.flags);
79 * @return the timeStamp
81 public Instant getTimeStamp() {
89 * the timeStamp to set
91 public void setTimeStamp(Instant timeStamp) {
92 this.timeStamp = timeStamp;
96 * Get the API version.
100 public String getApiVer() {
105 * Set the API version.
110 public void setApiVer(String apiVer) {
111 this.apiVer = apiVer;
115 * Get the request Id.
117 * @return the requestId
119 public UUID getRequestId() {
124 * Set the request Id.
127 * the requestId to set
129 public void setRequestId(UUID requestId) {
130 this.requestId = requestId;
134 * Get the sub request Id.
136 * @return the subRequestId
138 public String getSubRequestId() {
143 * Set the sub request Id.
145 * @param subRequestId
146 * the subRequestId to set
148 public void setSubRequestId(String subRequestId) {
149 this.subRequestId = subRequestId;
152 * Set the request track.
154 * @param requestTrack
155 * the requestTrack to set
157 public void setRequestTrack(Map<String, String> requestTrack) {
158 this.requestTrack = requestTrack;
161 * Get the request track.
163 * @return the requestTrack
165 public Map<String, String> getRequestTrack() {
174 public Map<String, String> getFlags() {
184 public void setFlags(Map<String, String> flags) {
189 public String toString() {
190 return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer
191 + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack
192 + ", flags=" + flags + "]";
196 public int hashCode() {
197 final int prime = 31;
199 result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
200 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
201 result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
202 result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
203 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
204 result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
209 public boolean equals(Object obj) {
216 if (getClass() != obj.getClass()) {
219 PciCommonHeader other = (PciCommonHeader) obj;
220 if (apiVer == null) {
221 if (other.apiVer != null) {
224 } else if (!apiVer.equals(other.apiVer)) {
228 if (other.flags != null) {
231 } else if (!flags.equals(other.flags)) {
234 if (requestTrack == null) {
235 if (other.requestTrack != null) {
238 } else if (!requestTrack.equals(other.requestTrack)) {
241 if (requestId == null) {
242 if (other.requestId != null) {
245 } else if (!requestId.equals(other.requestId)) {
248 if (subRequestId == null) {
249 if (other.subRequestId != null) {
252 } else if (!subRequestId.equals(other.subRequestId)) {
255 if (timeStamp == null) {
256 if (other.timeStamp != null) {
259 } else if (!timeStamp.equals(other.timeStamp)) {