Package org.mycore.util.concurrent
Interface MCRDecorator<V>
- All Known Implementing Classes:
MCRDelayedRunnable
,MCRFixedUserCallable
,MCRTransactionableCallable
,MCRTransactionableRunnable
public interface MCRDecorator<V>
Classes can implement this interface if they want to use
the decorator pattern. Contains some static helper methods
to check if an instance is implementing the decorator.
- Author:
- Matthias Eichner
-
Method Summary
Modifier and TypeMethodDescriptionget()
Returns the enclosing instance.static <V> Optional<V>
Returns an optional with the enclosing value of the decorator.static boolean
isDecorated
(Object decorator) Checks if the given object is decorated by this interface.static <V> Optional<V>
Same asget()
, but returns the last object which does not implement the decorator interface anymore.
-
Method Details
-
get
V get()Returns the enclosing instance.- Returns:
- the decorated instance
-
isDecorated
Checks if the given object is decorated by this interface.- Parameters:
decorator
- the interface to check- Returns:
- true if the instance is decorated by an MCRDecorator
-
get
Returns an optional with the enclosing value of the decorator. The decorator should implement theMCRDecorator
interface. If not, an empty optional is returned.- get: MCRDecorator -> MCRDecorator -> MCRDecorator -> object
- resolve: MCRDecorator -> MCRDecorator -> MCRDecorator -> object
- Parameters:
decorator
- the MCRDecorator- Returns:
- an optional with the decorated instance
-
resolve
Same asget()
, but returns the last object which does not implement the decorator interface anymore.- get: MCRDecorator -> MCRDecorator -> MCRDecorator -> object
- resolve: MCRDecorator -> MCRDecorator -> MCRDecorator -> object
- Parameters:
decorator
- the MCRDecorator- Returns:
- an optional with the decorated instance
-