[POLICY-11] Sample Query with variable arguments
[policy/drools-applications.git] / appc / src / main / java / org / openecomp / policy / appc / CommonHeader.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appc
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.policy.appc;
22
23 import java.io.Serializable;
24 import java.time.Instant;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.Map;
28 import java.util.UUID;
29
30 public class CommonHeader implements Serializable {
31
32         private static final long serialVersionUID = -3581658269910980336L;
33         
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>>();
41         
42         public CommonHeader() {
43                 
44         }
45         
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);
52                 }
53                 if (commonHeader.Flags != null) {
54                         this.Flags.addAll(commonHeader.Flags);
55                 }
56         }
57
58         @Override
59         public String toString() {
60                 return "CommonHeader [TimeStamp=" + TimeStamp + ", APIver=" + APIver + ", OriginatorID=" + OriginatorID
61                                 + ", RequestID=" + RequestID + ", SubrequestID=" + SubRequestID + ", RequestTrack=" + RequestTrack
62                                 + ", Flags=" + Flags + "]";
63         }
64         @Override
65         public int hashCode() {
66                 final int prime = 31;
67                 int result = 1;
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());
75                 return result;
76         }
77         @Override
78         public boolean equals(Object obj) {
79                 if (this == obj)
80                         return true;
81                 if (obj == null)
82                         return false;
83                 if (getClass() != obj.getClass())
84                         return false;
85                 CommonHeader other = (CommonHeader) obj;
86                 if (APIver == null) {
87                         if (other.APIver != null)
88                                 return false;
89                 } else if (!APIver.equals(other.APIver))
90                         return false;
91                 if (Flags == null) {
92                         if (other.Flags != null)
93                                 return false;
94                 } else if (!Flags.equals(other.Flags))
95                         return false;
96                 if (OriginatorID == null) {
97                         if (other.OriginatorID != null)
98                                 return false;
99                 } else if (!OriginatorID.equals(other.OriginatorID))
100                         return false;
101                 if (RequestID == null) {
102                         if (other.RequestID != null)
103                                 return false;
104                 } else if (!RequestID.equals(other.RequestID))
105                         return false;
106                 if (RequestTrack == null) {
107                         if (other.RequestTrack != null)
108                                 return false;
109                 } else if (!RequestTrack.equals(other.RequestTrack))
110                         return false;
111                 if (SubRequestID == null) {
112                         if (other.SubRequestID != null)
113                                 return false;
114                 } else if (!SubRequestID.equals(other.SubRequestID))
115                         return false;
116                 if (TimeStamp == null) {
117                         if (other.TimeStamp != null)
118                                 return false;
119                 } else if (!TimeStamp.equals(other.TimeStamp))
120                         return false;
121                 return true;
122         }
123         
124 }