Fix sonar issues
[vfc/nfvo/driver/vnfm/svnfm.git] / nokiav2 / driver / src / main / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / nokia / vnfm / notification / ProcessedNotification.java
1 /*
2  * Copyright 2016-2017, Nokia Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
17
18 import com.nokia.cbam.lcm.v32.model.OperationStatus;
19
20 import java.util.Objects;
21
22 /**
23  * Represents a notification successfully processed by the {@link LifecycleChangeNotificationManager}
24  */
25 class ProcessedNotification {
26     private String operationExecutionId;
27     //do not remove field the {@link LifecycleChangeNotificationManager} uses the equals
28     // method to compare notifications
29     private OperationStatus status;
30
31     ProcessedNotification(String operationExecutionId, OperationStatus status) {
32         this.operationExecutionId = operationExecutionId;
33         this.status = status;
34     }
35
36     /**
37      * @return the identifier of the operation
38      */
39     public String getOperationExecutionId() {
40         return operationExecutionId;
41     }
42
43     /**
44      * @param operationExecutionId the identifier of the operation
45      */
46     public void setOperationExecutionId(String operationExecutionId) {
47         this.operationExecutionId = operationExecutionId;
48     }
49
50     /**
51      * @return the status of the operation
52      */
53     public OperationStatus getStatus() {
54         return status;
55     }
56
57     /**
58      * @param status the status of the operation
59      */
60     public void setStatus(OperationStatus status) {
61         this.status = status;
62     }
63
64     @Override
65     //generated code. This is the recommended way to formulate equals
66     @SuppressWarnings({"squid:S00122", "squid:S1067"})
67     public boolean equals(Object o) {
68         if (this == o) return true;
69         if (o == null || getClass() != o.getClass()) return false;
70         ProcessedNotification that = (ProcessedNotification) o;
71         return Objects.equals(operationExecutionId, that.operationExecutionId) &&
72                 status == that.status;
73     }
74
75     @Override
76     public int hashCode() {
77         return Objects.hash(operationExecutionId, status);
78     }
79
80     @Override
81     public String toString() {
82         return "ProcessedNotification{" +
83                 "operationExecutionId=" + operationExecutionId + '"' +
84                 ", status=" + status +
85                 '}';
86     }
87 }