java.lang.Object
stormpot.internal.OrExpiration<T>
- Type Parameters:
T- The concrete poolable type.
- All Implemented Interfaces:
Expiration<T>
Provides a way to compose
Expirations.
Given two Expirations, this class considers that a slot is expired if any of the
Expiration returns true. This makes it easy to have an Expiration that
expires both on time (Expiration.after(long, TimeUnit)) and some other criteria.
- Since:
- 2.4
- Author:
- Guillaume Lederrey
-
Constructor Summary
ConstructorsConstructorDescriptionOrExpiration(Expiration<T> firstExpiration, Expiration<T> secondExpiration) Create a new instance with the given two expirations. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasExpired(SlotInfo<? extends T> info) Returnstrueif any of the givenExpirationhas expired.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface stormpot.Expiration
every, every, or
-
Constructor Details
-
OrExpiration
Create a new instance with the given two expirations.- Parameters:
firstExpiration- The first expiration to check.secondExpiration- The second expiration to check.
-
-
Method Details
-
hasExpired
Returnstrueif any of the givenExpirationhas expired.- Specified by:
hasExpiredin interfaceExpiration<T extends Poolable>- Parameters:
info- An informative representative of the slot being tested. Nevernull.- Returns:
trueif the Slot and Poolable in question should be deallocated,falseif it is valid and eligible for claiming.- Throws:
Exception- If checking the validity of the Slot or Poolable somehow went wrong. In this case, the Poolable will be assumed to be expired.
-