Package org.codehaus.groovy.ast.tools
Class ParameterUtils
java.lang.Object
org.codehaus.groovy.ast.tools.ParameterUtils
Utility methods for working with method and constructor parameters.
Provides predicates and comparison utilities for Parameter arrays, supporting
parameter equality checks, compatibility analysis, and varargs detection. Used extensively
in method resolution and signature matching during compilation and reflection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if the last parameter in the array is a varargs parameter (array type).static booleanparametersCompatible(Parameter[] source, Parameter[] target) Checks if source parameters are compatible with target parameters using type assignability.static booleanparametersEqual(Parameter[] a, Parameter[] b) Checks if two parameter arrays have equal types (exact type matching).static booleanparametersEqualWithWrapperType(Parameter[] a, Parameter[] b) Checks if two parameter arrays have equal types, treating wrapper and primitive types as equal.
-
Constructor Details
-
ParameterUtils
public ParameterUtils()
-
-
Method Details
-
isVargs
Checks if the last parameter in the array is a varargs parameter (array type).- Parameters:
parameters- the parameter array to check, may be null- Returns:
- true if the array is non-empty and ends with an array-typed parameter, false otherwise
- Since:
- 4.0.4
-
parametersEqual
Checks if two parameter arrays have equal types (exact type matching).- Parameters:
a- the first parameter array, may be nullb- the second parameter array, may be null- Returns:
- true if both arrays have the same length and parameter types match exactly, false otherwise
- Since:
- 2.5.0
- See Also:
-
parametersEqualWithWrapperType
Checks if two parameter arrays have equal types, treating wrapper and primitive types as equal.For example,
int.classandInteger.classare considered equal.- Parameters:
a- the first parameter array, may be nullb- the second parameter array, may be null- Returns:
- true if both arrays have the same length and parameter types match (with wrapper equivalence), false otherwise
- Since:
- 3.0.0
- See Also:
-
parametersCompatible
Checks if source parameters are compatible with target parameters using type assignability. Each parameter type in source must be assignable to the corresponding target parameter type.- Parameters:
source- the source parameter array (may be null)target- the target parameter array (may be null)- Returns:
- true if both arrays have the same length and all source types are assignable to target types, false otherwise
- Since:
- 3.0.0
- See Also:
-