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 Type
    Method
    Description
    get()
    Returns the enclosing instance.
    static <V> Optional<V>
    get(Object decorator)
    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>
    resolve(Object decorator)
    Same as get(), 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

      static boolean isDecorated(Object decorator)
      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

      static <V> Optional<V> get(Object decorator)
      Returns an optional with the enclosing value of the decorator. The decorator should implement the MCRDecorator 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

      static <V> Optional<V> resolve(Object decorator)
      Same as get(), 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