Fix Tech Debt/JUnit on control loop event POJOs
[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         private String  actor;
34         private String  operation;
35         private String  target;
36         private Instant start = Instant.now();
37         private Instant end;
38         private String  subRequestId;
39         private String  outcome;
40         private String  message;
41         
42         public ControlLoopOperation() {
43                 
44         }
45         
46         public ControlLoopOperation(ControlLoopOperation op) {
47                 if (op == null) {
48                         return;
49                 }
50                 
51                 this.actor = op.actor;
52                 this.operation = op.operation;
53                 this.target = op.target;
54                 this.start = op.start;
55                 this.end = op.end;
56                 this.subRequestId = op.subRequestId;
57                 this.outcome = op.outcome;
58                 this.message = op.message;
59         }
60
61         public String   toMessage() {
62                 return "actor="+actor+",operation="+operation+",target="+target+",subRequestId="+subRequestId;
63         }
64         
65         public String   toHistory() {
66                 return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message;
67         }
68         
69         public String getActor() {
70                 return actor;
71         }
72
73         public void setActor(String actor) {
74                 this.actor = actor;
75         }
76
77         public String getOperation() {
78                 return operation;
79         }
80
81         public void setOperation(String operation) {
82                 this.operation = operation;
83         }
84
85         public String getTarget() {
86                 return target;
87         }
88
89         public void setTarget(String target) {
90                 this.target = target;
91         }
92
93         public Instant getStart() {
94                 return start;
95         }
96
97         public void setStart(Instant start) {
98                 this.start = start;
99         }
100
101         public Instant getEnd() {
102                 return end;
103         }
104
105         public void setEnd(Instant end) {
106                 this.end = end;
107         }
108
109         public String getSubRequestId() {
110                 return subRequestId;
111         }
112
113         public void setSubRequestId(String subRequestId) {
114                 this.subRequestId = subRequestId;
115         }
116
117         public String getOutcome() {
118                 return outcome;
119         }
120
121         public void setOutcome(String outcome) {
122                 this.outcome = outcome;
123         }
124
125         public String getMessage() {
126                 return message;
127         }
128
129         public void setMessage(String message) {
130                 this.message = message;
131         }
132
133         @Override
134         public String toString() {
135                 return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
136                                 + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
137                                 + message + "]";
138         }
139
140         @Override
141         public int hashCode() {
142                 final int prime = 31;
143                 int result = 1;
144                 result = prime * result + ((actor == null) ? 0 : actor.hashCode());
145                 result = prime * result + ((end == null) ? 0 : end.hashCode());
146                 result = prime * result + ((message == null) ? 0 : message.hashCode());
147                 result = prime * result + ((operation == null) ? 0 : operation.hashCode());
148                 result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
149                 result = prime * result + ((start == null) ? 0 : start.hashCode());
150                 result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
151                 result = prime * result + ((target == null) ? 0 : target.hashCode());
152                 return result;
153         }
154
155         @Override
156         public boolean equals(Object obj) {
157                 if (this == obj)
158                         return true;
159                 if (obj == null)
160                         return false;
161                 if (getClass() != obj.getClass())
162                         return false;
163                 ControlLoopOperation other = (ControlLoopOperation) obj;
164                 if (actor == null) {
165                         if (other.actor != null)
166                                 return false;
167                 } else if (!actor.equals(other.actor))
168                         return false;
169                 if (end == null) {
170                         if (other.end != null)
171                                 return false;
172                 } else if (!end.equals(other.end))
173                         return false;
174                 if (message == null) {
175                         if (other.message != null)
176                                 return false;
177                 } else if (!message.equals(other.message))
178                         return false;
179                 if (operation == null) {
180                         if (other.operation != null)
181                                 return false;
182                 } else if (!operation.equals(other.operation))
183                         return false;
184                 if (outcome == null) {
185                         if (other.outcome != null)
186                                 return false;
187                 } else if (!outcome.equals(other.outcome))
188                         return false;
189                 if (start == null) {
190                         if (other.start != null)
191                                 return false;
192                 } else if (!start.equals(other.start))
193                         return false;
194                 if (subRequestId == null) {
195                         if (other.subRequestId != null)
196                                 return false;
197                 } else if (!subRequestId.equals(other.subRequestId))
198                         return false;
199                 if (target == null) {
200                         if (other.target != null)
201                                 return false;
202                 } else if (!target.equals(other.target))
203                         return false;
204                 return true;
205         }
206
207 }