Class Wrapper<T>
- java.lang.Object
-
- nl.talsmasoftware.context.delegation.Wrapper<T>
-
- Direct Known Subclasses:
DelegatingExecutorService,DelegatingFuture,WrapperWithContext
public abstract class Wrapper<T> extends Object
Base wrapper class offering anon-null delegatemethod.- Author:
- Sjoerd Talsma
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Tdelegate()Delegate method that can be overridden in case the delegate is not yet available at construction time or when there some strategy applicable that determines the delegate at runtime.booleanequals(Object other)inthashCode()protected TnonNullDelegate()Acessor to provide a guaranteed non-nulldelegate instance for use within delegation method implementations.StringtoString()
-
-
-
Constructor Detail
-
Wrapper
protected Wrapper(T delegate)
Constructor providing a delegate wrapped object.- Parameters:
delegate- The delegate object being wrapped. This may only benullif thedelegate()method is overridden to provide an alternative non-nullresult.
-
-
Method Detail
-
delegate
protected T delegate()
Delegate method that can be overridden in case the delegate is not yet available at construction time or when there some strategy applicable that determines the delegate at runtime.By default, the specified delegate value from the constructor is returned.
- Returns:
- The delegate for this wrapper.
-
nonNullDelegate
protected final T nonNullDelegate()
Acessor to provide a guaranteed non-nulldelegate instance for use within delegation method implementations.- Returns:
- The delegate for this wrapper (guaranteed to be non-
null). - Throws:
NullPointerException- with a specific message in case the delegate was null.
-
-