Java 17 Upgrade
[policy/models.git] / models-pdp / src / main / java / org / onap / policy / models / pdp / concepts / PdpEngineWorkerStatistics.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019-2020, 2023 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.models.pdp.concepts;
22
23 import jakarta.persistence.Embeddable;
24 import java.io.Serial;
25 import java.io.Serializable;
26 import lombok.Data;
27 import lombok.NoArgsConstructor;
28 import lombok.NonNull;
29 import org.onap.policy.models.pdp.enums.PdpEngineWorkerState;
30
31 @Embeddable
32 @Data
33 @NoArgsConstructor
34 public class PdpEngineWorkerStatistics implements Serializable {
35     @Serial
36     private static final long serialVersionUID = 8262176849743624013L;
37
38     private String engineId;
39     private PdpEngineWorkerState engineWorkerState;
40     private long engineTimeStamp;
41     private long eventCount;
42     private long lastExecutionTime;
43     private double averageExecutionTime;
44     private long upTime;
45     private long lastEnterTime;
46     private long lastStart;
47
48     /**
49      * Constructs the object, making a deep copy.
50      *
51      * @param source source from which to copy
52      */
53     public PdpEngineWorkerStatistics(@NonNull PdpEngineWorkerStatistics source) {
54         this.engineId = source.engineId;
55         this.engineWorkerState = source.engineWorkerState;
56         this.engineTimeStamp = source.engineTimeStamp;
57         this.eventCount = source.eventCount;
58         this.lastExecutionTime = source.lastExecutionTime;
59         this.averageExecutionTime = source.averageExecutionTime;
60         this.upTime = source.upTime;
61         this.lastEnterTime = source.lastEnterTime;
62         this.lastStart = source.lastStart;
63     }
64
65     /**
66      * Tidy up any superfluous information such as leading and trailing white space.
67      */
68     public void clean() {
69         if (engineId != null) {
70             engineId = engineId.trim();
71         }
72     }
73 }