public enum ArgumentTypeResolver extends java.lang.Enum<ArgumentTypeResolver> implements MethodDelegationBinder.AmbiguityResolver
MethodDelegationBinder.AmbiguityResolver
that resolves two conflicting bindings by considering most-specific types of target method parameters in the same manner
as the Java compiler resolves bindings of overloaded method.
This ambiguity resolver:
For example: If a source method only parameter was successfully bound one-to-one to the only parameters of the target methods
foo(Object)
and bar(String)
, this ambiguity resolver will detect that the String
type
is more specific than the Object
type and determine bar(String)
as the dominant binding.Modifier and Type | Class and Description |
---|---|
static class |
ArgumentTypeResolver.ParameterIndexToken
This token is used to mark a one-to-one binding of a source method parameter to a target method parameter.
|
protected static class |
ArgumentTypeResolver.PrimitiveTypePrecedence
A representation of the precedence of a most specific primitive type in the Java programming language.
|
MethodDelegationBinder.AmbiguityResolver.Compound, MethodDelegationBinder.AmbiguityResolver.Directional, MethodDelegationBinder.AmbiguityResolver.NoOp, MethodDelegationBinder.AmbiguityResolver.Resolution
Enum Constant and Description |
---|
INSTANCE
The singleton instance.
|
DEFAULT
Modifier and Type | Method and Description |
---|---|
MethodDelegationBinder.AmbiguityResolver.Resolution |
resolve(MethodDescription source,
MethodDelegationBinder.MethodBinding left,
MethodDelegationBinder.MethodBinding right)
Attempts to resolve to conflicting bindings.
|
private static MethodDelegationBinder.AmbiguityResolver.Resolution |
resolveByScore(int boundParameterScore)
Resolves the most specific method by their score.
|
private static MethodDelegationBinder.AmbiguityResolver.Resolution |
resolveRivalBinding(TypeDescription sourceParameterType,
int leftParameterIndex,
MethodDelegationBinder.MethodBinding left,
int rightParameterIndex,
MethodDelegationBinder.MethodBinding right)
Resolves two bindings by comparing their binding of similar arguments and determining their most specific types.
|
static ArgumentTypeResolver |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ArgumentTypeResolver[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ArgumentTypeResolver INSTANCE
public static ArgumentTypeResolver[] values()
for (ArgumentTypeResolver c : ArgumentTypeResolver.values()) System.out.println(c);
public static ArgumentTypeResolver valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullprivate static MethodDelegationBinder.AmbiguityResolver.Resolution resolveRivalBinding(TypeDescription sourceParameterType, int leftParameterIndex, MethodDelegationBinder.MethodBinding left, int rightParameterIndex, MethodDelegationBinder.MethodBinding right)
sourceParameterType
- The parameter type of the source methodleftParameterIndex
- The index of the parameter of the left method.left
- The left method's parameter binding.rightParameterIndex
- The index of the parameter of the right method.right
- The right method's parameter binding.private static MethodDelegationBinder.AmbiguityResolver.Resolution resolveByScore(int boundParameterScore)
Argument
annotation.boundParameterScore
- The difference of the scores of the left and the right method.public MethodDelegationBinder.AmbiguityResolver.Resolution resolve(MethodDescription source, MethodDelegationBinder.MethodBinding left, MethodDelegationBinder.MethodBinding right)
resolve
in interface MethodDelegationBinder.AmbiguityResolver
source
- The source method that was bound to both target methods.left
- The first successful binding of the source
method.right
- The second successful binding of the source
method.MethodDelegationBinder.AmbiguityResolver.Resolution.LEFT
indicates a successful binding to the left
binding while
MethodDelegationBinder.AmbiguityResolver.Resolution.RIGHT
indicates a successful binding to the right
binding.