public final class WrapperProxy extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isWrapper(Object obj)
Tests whether the specified object is a proxy of a wrapped object.
|
static <T> boolean |
isWrapper(T obj,
Class<? extends T> wrappedClass)
Tests whether the specified object is a proxy of a wrapped instance type
matching the provided
wrappedClass. |
static <T> T |
wrap(T obj,
T wrapper)
|
public static <T> T wrap(T obj,
T wrapper)
<T> of the specified
obj wrapping the provided wrapper instance. Method
invocations on the proxy instance will be handled as such:
wrapper instance will be invoked for methods that
exist in the wrapper instance.obj instance will be invoked for methods that do not
exist in the wrapper instance.obj
instance.
Note: The runtime type of the returned instance will not be
of a concrete class, but rather a composition of all super-interfaces of
the concrete class <T>. It is therefore not possible to cast the
instance returned by this method to a concrete class, but rather any
super-interface of the concrete class.
T - The type parameter of the specified arguments.obj - The target object instance to wrap.wrapper - The wrapping object.<T> of the specified
obj wrapping the provided wrapper instance, or,
wrapper if obj == wrapper, or if target or
wrapper is null.public static boolean isWrapper(Object obj)
obj - The object to test.NullPointerException - If obj is null.public static <T> boolean isWrapper(T obj,
Class<? extends T> wrappedClass)
wrappedClass.T - The common type of the proxy and wrapped instance.obj - The object to test.wrappedClass - The type of the instance wrapped by the specified
obj.wrappedClass.NullPointerException - If obj or wrappedClass is
null.Copyright © 2020. All rights reserved.