2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2020 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;
32 import lombok.EqualsAndHashCode;
39 public class CommonHeader implements Serializable {
40 private static final long serialVersionUID = -3581658269910980336L;
42 @SerializedName("TimeStamp")
43 private Instant timeStamp = Instant.now();
45 @SerializedName("APIver")
46 private String apiVer = "1.01";
48 @SerializedName("OriginatorID")
49 private String originatorId;
51 @SerializedName("RequestID")
52 private UUID requestId;
54 @SerializedName("SubRequestID")
55 private String subRequestId;
57 @SerializedName("RequestTrack")
58 private Collection<String> requestTrack = new ArrayList<>();
60 @SerializedName("Flags")
61 private Collection<Map<String, String>> flags = new ArrayList<>();
63 public CommonHeader() {
64 // Default constructor
68 * Construct an instance from an existing instance.
70 * @param commonHeader the existing instance
72 public CommonHeader(CommonHeader commonHeader) {
73 this.originatorId = commonHeader.originatorId;
74 this.requestId = commonHeader.requestId;
75 this.subRequestId = commonHeader.subRequestId;
76 this.timeStamp = commonHeader.getTimeStamp();
77 this.apiVer = commonHeader.getApiVer();
78 if (commonHeader.requestTrack != null) {
79 this.requestTrack.addAll(commonHeader.requestTrack);
81 if (commonHeader.flags != null) {
82 this.flags.addAll(commonHeader.flags);
87 public String toString() {
88 return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorId=" + originatorId
89 + ", RequestId=" + requestId + ", SubrequestId=" + subRequestId + ", RequestTrack=" + requestTrack
90 + ", Flags=" + flags + "]";