Top Description Inners Fields Constructors Methods
net.bytebuddy.implementation.bind

public final Enum ArgumentTypeResolver

extends Enum<ArgumentTypeResolver>
implements AmbiguityResolver
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver
Imports
net.bytebuddy.description.method.MethodDescription, .ParameterList, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.utility.nullability.MaybeNull

Implementation of an net.bytebuddy.implementation.bind.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:
  1. Checks for each parameter of the source method if a one-to-one parameter binding to both of the target methods exist.
  2. 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.
  3. If this result is dominant for both the left and the right target method, this resolver will consider the binding as ambiguous.
  4. 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.
Primitive types are considered dominant in the same manner as by the Java compiler.

 

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 and Inner Type Summary

Modifier and TypeClass and Description
public 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 enum
ArgumentTypeResolver.PrimitiveTypePrecedence

A representation of the precedence of a most specific primitive type in the Java programming language.

Field Summary

Modifier and TypeField and Description
public static final ArgumentTypeResolver
INSTANCE

The singleton instance.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MethodDelegationBinder.AmbiguityResolver.Resolution
resolve(MethodDescription
The source method that was bound to both target methods.
source
,
MethodDelegationBinder.MethodBinding
The first successful binding of the source method.
left
,
MethodDelegationBinder.MethodBinding
The second successful binding of the source method.
right
)

Implements net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.resolve.

Attempts to resolve to conflicting bindings.
private static MethodDelegationBinder.AmbiguityResolver.Resolution

Returns:

A resolution according to this score.
resolveByScore
(int
The difference of the scores of the left and the right method.
boundParameterScore
)

Resolves the most specific method by their score.

private static MethodDelegationBinder.AmbiguityResolver.Resolution

Returns:

A resolution according to the given parameters.
resolveRivalBinding
(TypeDescription
The parameter type of the source method
sourceParameterType
,
int
The index of the parameter of the left method.
leftParameterIndex
,
MethodDelegationBinder.MethodBinding
The left method's parameter binding.
left
,
int
The index of the parameter of the right method.
rightParameterIndex
,
MethodDelegationBinder.MethodBinding
The right method's parameter binding.
right
)

Resolves two bindings by comparing their binding of similar arguments and determining their most specific types.

public static ArgumentTypeResolver
public static ArgumentTypeResolver[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final ArgumentTypeResolver INSTANCE

The singleton instance.

Constructor Detail

ArgumentTypeResolverback to summary
private ArgumentTypeResolver()

Method Detail

resolveback to summary
public MethodDelegationBinder.AmbiguityResolver.Resolution resolve(MethodDescription source, MethodDelegationBinder.MethodBinding left, MethodDelegationBinder.MethodBinding right)

Implements net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.resolve.

Doc from net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.resolve.

Attempts to resolve to conflicting bindings.

Parameters
source:MethodDescription

The source method that was bound to both target methods.

left:MethodDelegationBinder.MethodBinding

The first successful binding of the source method.

right:MethodDelegationBinder.MethodBinding

The second successful binding of the source method.

Returns:MethodDelegationBinder.AmbiguityResolver.Resolution

The resolution state when resolving a conflicting binding where net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.Resolution#LEFT indicates a successful binding to the left binding while net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.Resolution#RIGHT indicates a successful binding to the right binding.

resolveByScoreback to summary
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 explicit net.bytebuddy.implementation.bind.annotation.Argument annotation.

Parameters
boundParameterScore:int

The difference of the scores of the left and the right method.

Returns:MethodDelegationBinder.AmbiguityResolver.Resolution

A resolution according to this score.

resolveRivalBindingback to summary
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:TypeDescription

The parameter type of the source method

leftParameterIndex:int

The index of the parameter of the left method.

left:MethodDelegationBinder.MethodBinding

The left method's parameter binding.

rightParameterIndex:int

The index of the parameter of the right method.

right:MethodDelegationBinder.MethodBinding

The right method's parameter binding.

Returns:MethodDelegationBinder.AmbiguityResolver.Resolution

A resolution according to the given parameters.

valueOfback to summary
public static ArgumentTypeResolver valueOf(String name)
valuesback to summary
public static ArgumentTypeResolver[] values()
net.bytebuddy.implementation.bind back to summary

public Class ArgumentTypeResolver.ParameterIndexToken

extends Object
Class Inheritance
  • java.lang.Object
  • net.bytebuddy.implementation.bind.ArgumentTypeResolver.ParameterIndexToken

This token is used to mark a one-to-one binding of a source method parameter to a target method parameter.
See Also
net.bytebuddy.implementation.bind.MethodDelegationBinder.MethodBinding#getTargetParameterIndex(Object)

Field Summary

Modifier and TypeField and Description
private final int
parameterIndex

The parameter index that is represented by this token.

Constructor Summary

AccessConstructor and Description
public
ParameterIndexToken(int
The parameter index of the source method which is mapped to a target method parameter.
parameterIndex
)

Create a parameter index token for a given parameter of the source method.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

parameterIndexback to summary
private final int parameterIndex

The parameter index that is represented by this token.

Annotations
@SuppressWarnings:unused

Constructor Detail

ParameterIndexTokenback to summary
public ParameterIndexToken(int parameterIndex)

Create a parameter index token for a given parameter of the source method.

Parameters
parameterIndex:int

The parameter index of the source method which is mapped to a target method parameter.

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
net.bytebuddy.implementation.bind back to summary

protected final Enum ArgumentTypeResolver.PrimitiveTypePrecedence

extends Enum<ArgumentTypeResolver.PrimitiveTypePrecedence>
Class Inheritance

A representation of the precedence of a most specific primitive type in the Java programming language.

Field Summary

Modifier and TypeField and Description
public static final ArgumentTypeResolver.PrimitiveTypePrecedence
BOOLEAN

The precedence of the boolean type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
BYTE

The precedence of the byte type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
CHARACTER

The precedence of the char type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
DOUBLE

The precedence of the double type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
FLOAT

The precedence of the float type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
INTEGER

The precedence of the int type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
LONG

The precedence of the long type.

private final int
score

A score representing the precedence where a higher score represents a less specific type.

public static final ArgumentTypeResolver.PrimitiveTypePrecedence
SHORT

The precedence of the short type.

Constructor Summary

AccessConstructor and Description
private
PrimitiveTypePrecedence(int
A score representing the precedence where a higher score represents a less specific type.
score
)

Creates a new primitive type precedence.

Method Summary

Modifier and TypeMethod and Description
public static ArgumentTypeResolver.PrimitiveTypePrecedence

Returns:

The corresponding primitive type precedence.
forPrimitive
(TypeDescription
The non-void, primitive type for which the precedence should be located.
typeDescription
)

Locates the primitive type precedence for a given type.

public MethodDelegationBinder.AmbiguityResolver.Resolution

Returns:

The resolution of
resolve
(ArgumentTypeResolver.PrimitiveTypePrecedence
Another primitive type precedence against which this precedence should be resolved.
right
)

Resolves the least specific type of two primitive type precedence with this instance representing a net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.Resolution#LEFT resolution and the argument type representing the net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.Resolution#RIGHT resolution.

public static ArgumentTypeResolver.PrimitiveTypePrecedence
public static ArgumentTypeResolver.PrimitiveTypePrecedence[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOOLEANback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence BOOLEAN

The precedence of the boolean type.

BYTEback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence BYTE

The precedence of the byte type.

CHARACTERback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence CHARACTER

The precedence of the char type.

DOUBLEback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence DOUBLE

The precedence of the double type.

FLOATback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence FLOAT

The precedence of the float type.

INTEGERback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence INTEGER

The precedence of the int type.

LONGback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence LONG

The precedence of the long type.

scoreback to summary
private final int score

A score representing the precedence where a higher score represents a less specific type.

SHORTback to summary
public static final ArgumentTypeResolver.PrimitiveTypePrecedence SHORT

The precedence of the short type.

Constructor Detail

PrimitiveTypePrecedenceback to summary
private PrimitiveTypePrecedence(int score)

Creates a new primitive type precedence.

Parameters
score:int

A score representing the precedence where a higher score represents a less specific type.

Method Detail

forPrimitiveback to summary
public static ArgumentTypeResolver.PrimitiveTypePrecedence forPrimitive(TypeDescription typeDescription)

Locates the primitive type precedence for a given type.

Parameters
typeDescription:TypeDescription

The non-void, primitive type for which the precedence should be located.

Returns:ArgumentTypeResolver.PrimitiveTypePrecedence

The corresponding primitive type precedence.

resolveback to summary
public MethodDelegationBinder.AmbiguityResolver.Resolution resolve(ArgumentTypeResolver.PrimitiveTypePrecedence right)

Resolves the least specific type of two primitive type precedence with this instance representing a net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.Resolution#LEFT resolution and the argument type representing the net.bytebuddy.implementation.bind.MethodDelegationBinder.AmbiguityResolver.Resolution#RIGHT resolution.

Parameters
right:ArgumentTypeResolver.PrimitiveTypePrecedence

Another primitive type precedence against which this precedence should be resolved.

Returns:MethodDelegationBinder.AmbiguityResolver.Resolution

The resolution of

valueOfback to summary
public static ArgumentTypeResolver.PrimitiveTypePrecedence valueOf(String name)
valuesback to summary
public static ArgumentTypeResolver.PrimitiveTypePrecedence[] values()