8e1bf9189d9928787bbd23bbdd79db4863da9abe
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  * http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter;
19
20 public class NotificationWithServerTimeStamp<T2> {
21     private final T2 alarmNotification;
22     private T2 contraAlarmNotification;
23     private final long timestampStart;
24     private long timestamp;
25
26     public NotificationWithServerTimeStamp(T2 n) {
27         this(n, System.currentTimeMillis());
28     }
29
30     public NotificationWithServerTimeStamp(T2 n, long ts) {
31         this.alarmNotification = n;
32         this.contraAlarmNotification = null;
33         this.timestamp = ts;
34         this.timestampStart = ts;
35     }
36
37     @SuppressWarnings("unused")
38     public long getStartTime() {
39         return this.timestampStart;
40     }
41
42     public void refresh() {
43         this.refresh(System.currentTimeMillis());
44     }
45
46     public void refresh(long ts) {
47         this.timestamp = ts;
48     }
49
50     public void setContraEvent(T2 notification) {
51         this.contraAlarmNotification = notification;
52         this.refresh();
53     }
54
55     public void clrContraEvent() {
56         this.contraAlarmNotification = null;
57         this.refresh();
58     }
59
60     public boolean isStable(long now) {
61         return this.timestamp + NotificationDelayFilter.getDelay() < now;
62     }
63
64     @SuppressWarnings("unused")
65     public T2 getAlarmNotification() {
66         return this.alarmNotification;
67     }
68
69     public T2 getContraAlarmNotification() {
70         return this.contraAlarmNotification;
71     }
72
73     @Override
74     public String toString() {
75         return "NotificationWithServerTimeStamp [alarmNotification=" + alarmNotification + ", contraAlarmNotification="
76                 + contraAlarmNotification + ", timestampStart=" + timestampStart + ", timestamp=" + timestamp + "]";
77     }
78 }