06f603069519797acfd3f19b238258500452b65c
[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 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 java.io.Serializable;
24 import javax.persistence.Embeddable;
25 import lombok.Data;
26 import lombok.NoArgsConstructor;
27 import lombok.NonNull;
28 import org.onap.policy.models.pdp.enums.PdpEngineWorkerState;
29
30 @Embeddable
31 @Data
32 @NoArgsConstructor
33 public class PdpEngineWorkerStatistics implements Serializable {
34     private static final long serialVersionUID = 8262176849743624013L;
35
36     private String engineId;
37     private PdpEngineWorkerState engineWorkerState;
38     private long engineTimeStamp;
39     private long eventCount;
40     private long lastExecutionTime;
41     private double averageExecutionTime;
42     private long upTime;
43     private long lastEnterTime;
44     private long lastStart;
45
46     /**
47      * Constructs the object, making a deep copy.
48      *
49      * @param source source from which to copy
50      */
51     public PdpEngineWorkerStatistics(@NonNull PdpEngineWorkerStatistics source) {
52         this.engineId = source.engineId;
53         this.engineWorkerState = source.engineWorkerState;
54         this.engineTimeStamp = source.engineTimeStamp;
55         this.eventCount = source.eventCount;
56         this.lastExecutionTime = source.lastExecutionTime;
57         this.averageExecutionTime = source.averageExecutionTime;
58         this.upTime = source.upTime;
59         this.lastEnterTime = source.lastEnterTime;
60         this.lastStart = source.lastStart;
61     }
62
63     /**
64      * Tidy up any superfluous information such as leading and trailing white space.
65      */
66     public void clean() {
67         if (engineId != null) {
68             engineId = engineId.trim();
69         }
70     }
71 }