-
Notifications
You must be signed in to change notification settings - Fork 188
/
CounterSpecification.java
79 lines (64 loc) · 2.14 KB
/
CounterSpecification.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) 2010-2018 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.repo.api;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyThresholdType;
/**
* @author katka
*
*/
public class CounterSpecification implements DebugDumpable {
private int count = 0;
private long counterStart;
private String oid;
private PolicyRuleType policyRule;
private String policyRuleId;
public CounterSpecification(String oid, String policyRuleId, PolicyRuleType policyRule) {
this.oid = oid;
this.policyRuleId = policyRuleId;
this.policyRule = policyRule;
}
public int getCount() {
return count;
}
public long getCounterStart() {
return counterStart;
}
public void setCount(int count) {
this.count = count;
}
public void setCounterStart(long counterStart) {
this.counterStart = counterStart;
}
public PolicyThresholdType getPolicyThreshold() {
return policyRule.getPolicyThreshold();
}
public String getPolicyRuleName() {
return policyRule.getName();
}
public String getOid() {
return oid;
}
public String getPolicyRuleId() {
return policyRuleId;
}
public void reset(long currentTimeMillis) {
count = 0;
counterStart = currentTimeMillis;
}
@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
sb.append("Counter for: ").append(oid).append(", policy rule: ").append(policyRule).append("\n");
sb.append("Current count: ").append(count).append("\n");
sb.append("Counter start: ").append(XmlTypeConverter.createXMLGregorianCalendar(counterStart)).append("\n");
sb.append("Thresholds: \n").append(getPolicyThreshold().toString());
return sb.toString();
}
}