[POLICY-11] Sample Query with variable arguments
[policy/drools-applications.git] / controlloop / common / model-impl / events / src / main / java / org / onap / policy / controlloop / ControlLoopOperation.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * controlloop
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.onap.policy.controlloop;
22
23 import java.io.Serializable;
24 import java.time.Instant;
25
26 public class ControlLoopOperation implements Serializable {
27
28         /**
29          * 
30          */
31         private static final long serialVersionUID = 8662706581293017099L;
32         
33         public String   actor;
34         public String   operation;
35         public String   target;
36         public Instant  start = Instant.now();
37         public Instant  end;
38         public String   subRequestId;
39         public String   outcome;
40         public String   message;
41         
42         public ControlLoopOperation() {
43                 
44         }
45         
46         public ControlLoopOperation(ControlLoopOperation op) {
47                 this.actor = op.actor;
48                 this.operation = op.operation;
49                 this.target = op.target;
50                 this.start = op.start;
51                 this.end = op.end;
52                 this.subRequestId = op.subRequestId;
53                 this.outcome = op.outcome;
54                 this.message = op.message;
55         }
56
57         public String   toMessage() {
58                 return "actor="+actor+",operation="+operation+",target="+target+",subRequestId="+subRequestId;
59         }
60         
61         public String   toHistory() {
62                 return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message;
63         }
64         
65         @Override
66         public String toString() {
67                 return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
68                                 + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
69                                 + message + "]";
70         }
71
72         @Override
73         public int hashCode() {
74                 final int prime = 31;
75                 int result = 1;
76                 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
77                 result = prime * result + ((end == null) ? 0 : end.hashCode());
78                 result = prime * result + ((message == null) ? 0 : message.hashCode());
79                 result = prime * result + ((operation == null) ? 0 : operation.hashCode());
80                 result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
81                 result = prime * result + ((start == null) ? 0 : start.hashCode());
82                 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
83                 result = prime * result + ((target == null) ? 0 : target.hashCode());
84                 return result;
85         }
86
87         @Override
88         public boolean equals(Object obj) {
89                 if (this == obj)
90                         return true;
91                 if (obj == null)
92                         return false;
93                 if (getClass() != obj.getClass())
94                         return false;
95                 ControlLoopOperation other = (ControlLoopOperation) obj;
96                 if (actor == null) {
97                         if (other.actor != null)
98                                 return false;
99                 } else if (!actor.equals(other.actor))
100                         return false;
101                 if (end == null) {
102                         if (other.end != null)
103                                 return false;
104                 } else if (!end.equals(other.end))
105                         return false;
106                 if (message == null) {
107                         if (other.message != null)
108                                 return false;
109                 } else if (!message.equals(other.message))
110                         return false;
111                 if (operation == null) {
112                         if (other.operation != null)
113                                 return false;
114                 } else if (!operation.equals(other.operation))
115                         return false;
116                 if (outcome == null) {
117                         if (other.outcome != null)
118                                 return false;
119                 } else if (!outcome.equals(other.outcome))
120                         return false;
121                 if (start == null) {
122                         if (other.start != null)
123                                 return false;
124                 } else if (!start.equals(other.start))
125                         return false;
126                 if (subRequestId == null) {
127                         if (other.subRequestId != null)
128                                 return false;
129                 } else if (!subRequestId.equals(other.subRequestId))
130                         return false;
131                 if (target == null) {
132                         if (other.target != null)
133                                 return false;
134                 } else if (!target.equals(other.target))
135                         return false;
136                 return true;
137         }
138
139 }