2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T 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.openecomp.policy.appc;
23 import java.io.Serializable;
24 import java.time.Instant;
25 import java.util.ArrayList;
26 import java.util.Collection;
28 import java.util.UUID;
30 public class CommonHeader implements Serializable {
32 private static final long serialVersionUID = -3581658269910980336L;
34 public Instant TimeStamp = Instant.now();
35 public String APIver = "1.01";
36 public String OriginatorID;
37 public UUID RequestID;
38 public String SubRequestID;
39 public Collection<String> RequestTrack = new ArrayList<String>();
40 public Collection<Map<String, String>> Flags = new ArrayList<Map<String, String>>();
42 public CommonHeader() {
46 public CommonHeader(CommonHeader commonHeader) {
47 this.OriginatorID = commonHeader.OriginatorID;
48 this.RequestID = commonHeader.RequestID;
49 this.SubRequestID = commonHeader.SubRequestID;
50 if (commonHeader.RequestTrack != null) {
51 this.RequestTrack.addAll(commonHeader.RequestTrack);
53 if (commonHeader.Flags != null) {
54 this.Flags.addAll(commonHeader.Flags);
59 public String toString() {
60 return "CommonHeader [TimeStamp=" + TimeStamp + ", APIver=" + APIver + ", OriginatorID=" + OriginatorID
61 + ", RequestID=" + RequestID + ", SubrequestID=" + SubRequestID + ", RequestTrack=" + RequestTrack
62 + ", Flags=" + Flags + "]";
65 public int hashCode() {
68 result = prime * result + ((APIver == null) ? 0 : APIver.hashCode());
69 result = prime * result + ((Flags == null) ? 0 : Flags.hashCode());
70 result = prime * result + ((OriginatorID == null) ? 0 : OriginatorID.hashCode());
71 result = prime * result + ((RequestID == null) ? 0 : RequestID.hashCode());
72 result = prime * result + ((RequestTrack == null) ? 0 : RequestTrack.hashCode());
73 result = prime * result + ((SubRequestID == null) ? 0 : SubRequestID.hashCode());
74 result = prime * result + ((TimeStamp == null) ? 0 : TimeStamp.hashCode());
78 public boolean equals(Object obj) {
83 if (getClass() != obj.getClass())
85 CommonHeader other = (CommonHeader) obj;
87 if (other.APIver != null)
89 } else if (!APIver.equals(other.APIver))
92 if (other.Flags != null)
94 } else if (!Flags.equals(other.Flags))
96 if (OriginatorID == null) {
97 if (other.OriginatorID != null)
99 } else if (!OriginatorID.equals(other.OriginatorID))
101 if (RequestID == null) {
102 if (other.RequestID != null)
104 } else if (!RequestID.equals(other.RequestID))
106 if (RequestTrack == null) {
107 if (other.RequestTrack != null)
109 } else if (!RequestTrack.equals(other.RequestTrack))
111 if (SubRequestID == null) {
112 if (other.SubRequestID != null)
114 } else if (!SubRequestID.equals(other.SubRequestID))
116 if (TimeStamp == null) {
117 if (other.TimeStamp != null)
119 } else if (!TimeStamp.equals(other.TimeStamp))