Enum Class ArgumentTypeResolver
- All Implemented Interfaces:
Serializable
,Comparable<ArgumentTypeResolver>
,Constable
,MethodDelegationBinder.AmbiguityResolver
public enum ArgumentTypeResolver
extends Enum<ArgumentTypeResolver>
implements MethodDelegationBinder.AmbiguityResolver
Implementation of an
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:
- Checks for each parameter of the source method if a one-to-one parameter binding to both of the target methods exist.
- If any of the source method parameters were bound one-to-one to both target methods, the method with the most specific type is considered as dominant.
- If this result is dominant for both the left and the right target method, this resolver will consider the binding as ambiguous.
- If none of the methods is dominant and if the comparison did not result in an ambiguous resolution, the method that consists of the most one-to-one parameter bindings is considered dominant.
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This token is used to mark a one-to-one binding of a source method parameter to a target method parameter.protected static enum
A representation of the precedence of a most specific primitive type in the Java programming language.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver
MethodDelegationBinder.AmbiguityResolver.Compound, MethodDelegationBinder.AmbiguityResolver.Directional, MethodDelegationBinder.AmbiguityResolver.NoOp, MethodDelegationBinder.AmbiguityResolver.Resolution
-
Enum Constant Summary
Enum Constants -
Field Summary
Fields inherited from interface net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver
DEFAULT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionresolve
(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
Returns the enum constant of this class with the specified name.static ArgumentTypeResolver[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
The singleton instance.
-
-
Constructor Details
-
ArgumentTypeResolver
private ArgumentTypeResolver()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
resolveRivalBinding
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.- Parameters:
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.- Returns:
- A resolution according to the given parameters.
-
resolveByScore
private static MethodDelegationBinder.AmbiguityResolver.Resolution resolveByScore(int boundParameterScore) Resolves the most specific method by their score. A method's score is calculated by the absolute number of parameters that were bound by using an explicitArgument
annotation.- Parameters:
boundParameterScore
- The difference of the scores of the left and the right method.- Returns:
- A resolution according to this score.
-
resolve
public MethodDelegationBinder.AmbiguityResolver.Resolution resolve(MethodDescription source, MethodDelegationBinder.MethodBinding left, MethodDelegationBinder.MethodBinding right) Attempts to resolve to conflicting bindings.- Specified by:
resolve
in interfaceMethodDelegationBinder.AmbiguityResolver
- Parameters:
source
- The source method that was bound to both target methods.left
- The first successful binding of thesource
method.right
- The second successful binding of thesource
method.- Returns:
- The resolution state when resolving a conflicting binding where
MethodDelegationBinder.AmbiguityResolver.Resolution.LEFT
indicates a successful binding to theleft
binding whileMethodDelegationBinder.AmbiguityResolver.Resolution.RIGHT
indicates a successful binding to theright
binding.
-