public class TimedExpirySupport
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
expired |
protected long |
expiryTime |
protected long |
maxExpiryTime |
protected long |
minExpiryTime |
protected static java.util.Random |
rand |
Constructor and Description |
---|
TimedExpirySupport()
Constructs an instance with minimum expiry interval of 1 second and a max of 2 seconds.
|
TimedExpirySupport(long minExpiryTime,
long maxExpiryTime)
Constructs an instance with specified minimum and maximum expiry intervals.
|
Modifier and Type | Method and Description |
---|---|
long |
getExpiryTime()
Indicates the current expiration time, which is a random value between the specified minimum and maximum.
|
long |
getMaxExpiryTime()
Indicates this timer's maximum expiry interval.
|
long |
getMinExpiryTime()
Indicates this timer's minimum expiry interval.
|
boolean |
isExpired(DrawContext dc)
Indicates whether this timer has expired.
|
boolean |
isExpired(long now)
Indicates whether this timer has expired.
|
void |
restart(DrawContext dc)
Marks this timer as not expired and restarts the timer.
|
void |
setExpired(boolean expired)
Set the expiration state of this timer.
|
void |
setExpiryTime(long expiryTime)
Sets the current expiration time to a specified value.
|
void |
setExpiryTime(long minExpiryTime,
long maxExpiryTime)
Specifies the minimum and maximum expiration intervals.
|
protected boolean expired
protected long expiryTime
protected long maxExpiryTime
protected long minExpiryTime
protected static java.util.Random rand
public TimedExpirySupport()
public TimedExpirySupport(long minExpiryTime, long maxExpiryTime)
minExpiryTime
- the minimum interval allowed to pass before expiration, in milliseconds.maxExpiryTime
- the maximum interval allowed to pass before expiration, in milliseconds.public long getExpiryTime()
public long getMaxExpiryTime()
public long getMinExpiryTime()
public boolean isExpired(DrawContext dc)
dc
- the current draw context.java.lang.IllegalArgumentException
- if the draw context is null.public boolean isExpired(long now)
now
- the time to relate this timer's expiration time to. The timer is considered expired if this timer's
expiry time is less than this value.public void restart(DrawContext dc)
dc
- the current draw context.java.lang.IllegalArgumentException
- if the draw context is null.public void setExpired(boolean expired)
expired
- true to indicate expired, false to indicate not expired.public void setExpiryTime(long expiryTime)
expiryTime
- the new expiration time, in milliseconds.public void setExpiryTime(long minExpiryTime, long maxExpiryTime)
minExpiryTime
- the minimum interval allowed to pass before expiration, in milliseconds.maxExpiryTime
- the maximum interval allowed to pass before expiration, in milliseconds.