0b3e9879554810d63b1cf35b7396e1a2163209a0
[policy/models.git] / models-interactions / model-impl / sdnr / src / main / java / org / onap / policy / sdnr / PciCommonHeader.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdnr
4  * ================================================================================
5  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * Modifications Copyright (C) 2019-2020 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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  */
22
23 package org.onap.policy.sdnr;
24
25 import com.google.gson.annotations.SerializedName;
26
27 import java.io.Serializable;
28 import java.time.Instant;
29 import java.util.HashMap;
30 import java.util.Map;
31 import java.util.UUID;
32 import lombok.EqualsAndHashCode;
33 import lombok.Getter;
34 import lombok.Setter;
35
36 @Getter
37 @Setter
38 @EqualsAndHashCode
39 public class PciCommonHeader implements Serializable {
40
41     private static final long serialVersionUID = 5435363539127062114L;
42
43     @SerializedName(value = "TimeStamp")
44     private Instant timeStamp = Instant.now();
45
46     @SerializedName(value = "APIVer")
47     private String apiVer = "1.0";
48
49     @SerializedName(value = "RequestID")
50     private UUID requestId;
51
52     @SerializedName(value = "SubRequestID")
53     private String subRequestId;
54
55     @SerializedName(value = "RequestTrack")
56     private Map<String, String> requestTrack = new HashMap<>();
57
58     @SerializedName(value = "Flags")
59     private Map<String, String> flags = new HashMap<>();
60
61     public PciCommonHeader() {
62
63     }
64
65     /**
66      * Used to copy a pci common header.
67      *
68      * @param commonHeader a header that is defined by the Pci api guide that contains information
69      *        about the request (requestId, flags, etc.)
70      */
71     public PciCommonHeader(PciCommonHeader commonHeader) {
72         this.timeStamp = commonHeader.timeStamp;
73         this.requestId = commonHeader.requestId;
74         this.subRequestId = commonHeader.subRequestId;
75         this.apiVer = commonHeader.getApiVer();
76         if (commonHeader.requestTrack != null) {
77             this.requestTrack.putAll(commonHeader.requestTrack);
78         }
79         if (commonHeader.flags != null) {
80             this.flags.putAll(commonHeader.flags);
81         }
82     }
83
84     @Override
85     public String toString() {
86         return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer
87                    + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack
88                    + ", flags=" + flags + "]";
89     }
90 }