public class Delegating
extends java.lang.Object
Such a proxy is used to mask the methods of an object, that are not part of a public interface. Or it is used to make an object compatible, e.g. when an object implements the methods of an interface, but does not implement the interface itself.
com.thoughtworks.proxy.toys.delegate
Modifier and Type | Field and Description |
---|---|
static boolean |
DYNAMIC_TYPING
Deprecated.
since 0.2, use
MODE_SIGNATURE |
static int |
MODE_DIRECT
Delegate must implement the method's interface
|
static int |
MODE_SIGNATURE
Delegate must have method with same name and matching signature - not necessarily the same
|
static boolean |
STATIC_TYPING
Deprecated.
since 0.2, use
MODE_DIRECT |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
object(java.lang.Class type,
java.lang.Object delegate)
Creating a delegating proxy for a signature compatible object.
|
static java.lang.Object |
object(java.lang.Class type,
java.lang.Object delegate,
int delegationMode)
Creating a delegating proxy for an object with a defined delegation mode.
|
static java.lang.Object |
object(java.lang.Class type,
java.lang.Object delegate,
ProxyFactory factory)
Creating a delegating proxy for a signature compatible object using a special
ProxyFactory . |
static java.lang.Object |
object(java.lang.Class type,
java.lang.Object delegate,
ProxyFactory factory,
int delegationMode)
Creating a delegating proxy for an object with a defined delegation mode using a special
ProxyFactory . |
public static final boolean STATIC_TYPING
MODE_DIRECT
public static final boolean DYNAMIC_TYPING
MODE_SIGNATURE
public static final int MODE_DIRECT
public static final int MODE_SIGNATURE
public static java.lang.Object object(java.lang.Class type, java.lang.Object delegate)
type
- the type of the created proxy,delegate
- the object the proxy delegates to.public static java.lang.Object object(java.lang.Class type, java.lang.Object delegate, int delegationMode)
type
- the type of the created proxy,delegate
- the object the proxy delegates to.delegationMode
- one of the delegation modes MODE_DIRECT
or MODE_SIGNATURE
java.lang.IllegalArgumentException
- if the delegationMode is not one of the predefined constantspublic static java.lang.Object object(java.lang.Class type, java.lang.Object delegate, ProxyFactory factory)
ProxyFactory
.type
- the type of the created proxy,delegate
- the object the proxy delegates to.factory
- the ProxyFactory
to use creating the proxy.public static java.lang.Object object(java.lang.Class type, java.lang.Object delegate, ProxyFactory factory, int delegationMode)
ProxyFactory
.type
- the type of the created proxy,delegate
- the object the proxy delegates to.factory
- the ProxyFactory
to use creating the proxy.delegationMode
- one of the delegation modes MODE_DIRECT
or MODE_SIGNATURE