1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.core.api.mo.common.active; |
18 | |
|
19 | |
import java.sql.Timestamp; |
20 | |
|
21 | 0 | public abstract class InactivatableFromToImpl implements InactivatableFromTo { |
22 | |
protected Timestamp activeFromDate; |
23 | |
protected Timestamp activeToDate; |
24 | |
|
25 | |
|
26 | |
@Override |
27 | |
public Timestamp getActiveFromDate() { |
28 | 0 | return activeFromDate; |
29 | |
} |
30 | |
|
31 | |
@Override |
32 | |
public Timestamp getActiveToDate() { |
33 | 0 | return activeToDate; |
34 | |
} |
35 | |
|
36 | |
|
37 | |
public boolean isActive() { |
38 | 0 | long asOfDate = System.currentTimeMillis(); |
39 | |
|
40 | 0 | return computeActive(asOfDate); |
41 | |
} |
42 | |
|
43 | |
|
44 | |
public boolean isActive(Timestamp activeAsOfDate) { |
45 | 0 | long asOfDate = System.currentTimeMillis(); |
46 | 0 | if (activeAsOfDate != null) { |
47 | 0 | asOfDate = activeAsOfDate.getTime(); |
48 | |
} |
49 | |
|
50 | 0 | return computeActive(asOfDate); |
51 | |
} |
52 | |
|
53 | |
|
54 | |
private boolean computeActive(Long asOfDate) { |
55 | 0 | return (activeFromDate == null || asOfDate >= activeFromDate.getTime()) |
56 | |
&& (activeToDate == null || asOfDate < activeToDate.getTime()); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
} |