org.ehcache.expiry
Class Duration

java.lang.Object
  extended by org.ehcache.expiry.Duration

public final class Duration
extends java.lang.Object

A unit of time in a given TimeUnit


Field Summary
static Duration FOREVER
          Special Duration value that indicates an infinite amount of time.
static Duration ZERO
          Special Duration value to represent a zero length duration
 
Constructor Summary
Duration(long amount, java.util.concurrent.TimeUnit timeUnit)
          Construct a Duration instance
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 long getAmount()
          Get the amount of getTimeUnit() this instance represents
 java.util.concurrent.TimeUnit getTimeUnit()
          Get the TimeUnit of this instance
 int hashCode()
           
 boolean isForever()
          Is this duration "forever" / infinite
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FOREVER

public static final Duration FOREVER
Special Duration value that indicates an infinite amount of time. This constant should be used to express a lack of a concrete expiration time (ie. "eternal").


ZERO

public static final Duration ZERO
Special Duration value to represent a zero length duration

Constructor Detail

Duration

public Duration(long amount,
                java.util.concurrent.TimeUnit timeUnit)
Construct a Duration instance

Parameters:
amount - the amount of the given time unit
timeUnit - the time unit
Throws:
java.lang.IllegalArgumentException - if the given amount is less than zero
java.lang.NullPointerException - if the given time unit is null
Method Detail

getAmount

public long getAmount()
Get the amount of getTimeUnit() this instance represents

Returns:
the amount of this instance
Throws:
java.lang.IllegalStateException - if this instance is FOREVER

getTimeUnit

public java.util.concurrent.TimeUnit getTimeUnit()
Get the TimeUnit of this instance

Returns:
timeunit the TimeUnit of this instance
Throws:
java.lang.IllegalStateException - if this instance is FOREVER

isForever

public boolean isForever()
Is this duration "forever" / infinite

Returns:
true if this instance is the special value FOREVER

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object