public class ConstrainableProxyUtil extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
equivalentConstraints(MethodConstraints methodConstraints1,
MethodConstraints methodConstraints2,
Method[] mappings)
Test to see if two
MethodConstraints instances are
equivalent given a method-to-method mapping. |
static MethodConstraints |
translateConstraints(MethodConstraints methodConstraints,
Method[] mappings)
Creates a
MethodConstraints using the constraints in
methodConstraints , but with the methods remapped according
to mappings , where the first element of each pair of
elements is mapped to the second. |
static void |
verifyConsistentConstraints(MethodConstraints methodConstraints,
Object proxy,
Method[] mappings)
Verify that an object,
proxy , is an instance of
RemoteMethodControl its MethodConstraints are
equivalent to another MethodConstraints instance,
methodConstraints once a mapping has been applied. |
public static MethodConstraints translateConstraints(MethodConstraints methodConstraints, Method[] mappings)
MethodConstraints
using the constraints in
methodConstraints
, but with the methods remapped according
to mappings
, where the first element of each pair of
elements is mapped to the second. For example, if
methodConstraints
returns constraints C1
for
method M1
, and the elements of mappings are methods
M1
and M2
, then the resulting method
constraints return C1
for method M2
.methodConstraints
- the method constraints whose methods should be
translated, or null
for empty constraintsmappings
- the method mappingsNullPointerException
- if mappings
is
null
or contains null
elementsIllegalArgumentException
- if mappings
contains an
odd number of elementspublic static boolean equivalentConstraints(MethodConstraints methodConstraints1, MethodConstraints methodConstraints2, Method[] mappings)
MethodConstraints
instances are
equivalent given a method-to-method mapping. Only the
constraints for methods that appear in the mapping are
compared. The mapping is represented by an array,
mappings
, of 2n Method
objects. For all values
p less than n the constraints associated with
mappings[2p]
in methodConstraints1
are compared to the constraints associated with
mappings[2p+1]
in
methodConstraints2
. If null is passed in for both
instances they are considered equivalent.methodConstraints1
- the first MethodConstraints
object to compare.methodConstraints2
- the second MethodConstraints
object to compare.mappings
- the method-to-method mapping.true
if the MethodConstraints
instances represent equivalent constraints, returns
false
otherwise.NullPointerException
- if mapping
is
null
contains null
elements.IllegalArgumentException
- if mapping
contains an
odd number of elementspublic static void verifyConsistentConstraints(MethodConstraints methodConstraints, Object proxy, Method[] mappings) throws InvalidObjectException
proxy
, is an instance of
RemoteMethodControl
its MethodConstraints
are
equivalent to another MethodConstraints
instance,
methodConstraints
once a mapping has been applied.
If proxy
does not implement
RemoteMethodControl
or the associated constraints are
not equivalent throw an InvalidObjectException
. The
mapping is represented by an array, mappings
, of
2n Method
objects. For all values p less than n the
constraints associated with mappings[2p]
in
methodConstraints
are compared to the constraints
associated with mappings[2p+1]
in the
MethodConstraints
returned by
proxy.getConstraints
. Will also return normally if
both methodConstraints
and the value returned by
proxy.getConstraints
are null
.methodConstraints
- the method constraints
proxy
should have.proxy
- the proxy to test, must implement
RemoteMethodControl
.mappings
- the method to method mappingNullPointerException
- if mappings
or
proxy
is null
or if
mapping
contains null
elementsIllegalArgumentException
- if mappings
contains an
odd number of elementsInvalidObjectException
- if proxy
does
not implement RemoteMethodControl
, or if
the constraints on proxy
are not
equivalent to methodConstraints
.Copyright © 2016–2018. All rights reserved.