Package com.linecorp.armeria.common.util
Class AbstractUnwrappable<T extends Unwrappable>
java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<T>
- Type Parameters:
T- the type of the object being decorated
- All Implemented Interfaces:
Unwrappable
- Direct Known Subclasses:
BackoffWrapper,ConnectionPoolListenerWrapper,DecoratingClient,DecoratingClientFactory,DecoratingService,RequestContextStorageWrapper,RequestContextWrapper,UserClient
public abstract class AbstractUnwrappable<T extends Unwrappable>
extends Object
implements Unwrappable
Skeletal
Unwrappable implementation.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractUnwrappable(T delegate) Creates a new decorator with the specified delegate. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper
-
Constructor Details
-
AbstractUnwrappable
Creates a new decorator with the specified delegate.
-
-
Method Details
-
as
Description copied from interface:UnwrappableUnwraps this object into the object of the specifiedtype. Use this method instead of an explicit downcast. For example:class Foo {} class Bar<T> extends AbstractWrapper<T> { Bar(T delegate) { super(delegate); } } class Qux<T> extends AbstractWrapper<T> { Qux(T delegate) { super(delegate); } } Qux qux = new Qux(new Bar(new Foo())); Foo foo = qux.as(Foo.class); Bar bar = qux.as(Bar.class);- Specified by:
asin interfaceUnwrappable- Parameters:
type- the type of the object to return- Returns:
- the object of the specified
typeif found, ornullif not found.
-
unwrap
Description copied from interface:UnwrappableUnwraps this object and returns the object being decorated. If thisUnwrappableis the innermost object, this method returns itself. For example:class Foo implements Unwrappable {} class Bar<T extends Unwrappable> extends AbstractUnwrappable<T> { Bar(T delegate) { super(delegate); } } class Qux<T extends Unwrappable> extends AbstractUnwrappable<T> { Qux(T delegate) { super(delegate); } } Foo foo = new Foo(); assert foo.unwrap() == foo; Bar<Foo> bar = new Bar<>(foo); assert bar.unwrap() == foo; Qux<Bar<Foo>> qux = new Qux<>(bar); assert qux.unwrap() == bar; assert qux.unwrap().unwrap() == foo;- Specified by:
unwrapin interfaceUnwrappable
-
unwrapAll
Description copied from interface:UnwrappableUnwraps this object and returns the innermost object being decorated. If thisUnwrappableis the innermost object, this method returns itself. For example:class Foo implements Unwrappable {} class Bar<T extends Unwrappable> extends AbstractUnwrappable<T> { Bar(T delegate) { super(delegate); } } class Qux<T extends Unwrappable> extends AbstractUnwrappable<T> { Qux(T delegate) { super(delegate); } } Foo foo = new Foo(); assert foo.unwrapAll() == foo; Bar<Foo> bar = new Bar<>(foo); assert bar.unwrapAll() == foo; Qux<Bar<Foo>> qux = new Qux<>(bar); assert qux.unwrap() == bar; assert qux.unwrapAll() == foo;- Specified by:
unwrapAllin interfaceUnwrappable
-
toString
-