Package org.apache.ibatis.reflection
Class ParamNameResolver
- java.lang.Object
-
- org.apache.ibatis.reflection.ParamNameResolver
-
public class ParamNameResolver extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
GENERIC_NAME_PREFIX
private boolean
hasParamAnnotation
private java.util.SortedMap<java.lang.Integer,java.lang.String>
names
The key is the index and the value is the name of the parameter.
The name is obtained fromParam
if specified.private boolean
useActualParamName
-
Constructor Summary
Constructors Constructor Description ParamNameResolver(Configuration config, java.lang.reflect.Method method)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
getActualParamName(java.lang.reflect.Method method, int paramIndex)
java.lang.Object
getNamedParams(java.lang.Object[] args)
A single non-special parameter is returned without a name.java.lang.String[]
getNames()
Returns parameter names referenced by SQL providers.private static boolean
isSpecialParameter(java.lang.Class<?> clazz)
static java.lang.Object
wrapToMapIfCollection(java.lang.Object object, java.lang.String actualParamName)
Wrap to aMapperMethod.ParamMap
if object isCollection
or array.
-
-
-
Field Detail
-
GENERIC_NAME_PREFIX
public static final java.lang.String GENERIC_NAME_PREFIX
- See Also:
- Constant Field Values
-
useActualParamName
private final boolean useActualParamName
-
names
private final java.util.SortedMap<java.lang.Integer,java.lang.String> names
The key is the index and the value is the name of the parameter.
The name is obtained fromParam
if specified. WhenParam
is not specified, the parameter index is used. Note that this index could be different from the actual index when the method has special parameters (i.e.RowBounds
orResultHandler
).- aMethod(@Param("M") int a, @Param("N") int b) -> {{0, "M"}, {1, "N"}}
- aMethod(int a, int b) -> {{0, "0"}, {1, "1"}}
- aMethod(int a, RowBounds rb, int b) -> {{0, "0"}, {2, "1"}}
-
hasParamAnnotation
private boolean hasParamAnnotation
-
-
Constructor Detail
-
ParamNameResolver
public ParamNameResolver(Configuration config, java.lang.reflect.Method method)
-
-
Method Detail
-
getActualParamName
private java.lang.String getActualParamName(java.lang.reflect.Method method, int paramIndex)
-
isSpecialParameter
private static boolean isSpecialParameter(java.lang.Class<?> clazz)
-
getNames
public java.lang.String[] getNames()
Returns parameter names referenced by SQL providers.- Returns:
- the names
-
getNamedParams
public java.lang.Object getNamedParams(java.lang.Object[] args)
A single non-special parameter is returned without a name. Multiple parameters are named using the naming rule. In addition to the default names, this method also adds the generic names (param1, param2, ...).
- Parameters:
args
- the args- Returns:
- the named params
-
wrapToMapIfCollection
public static java.lang.Object wrapToMapIfCollection(java.lang.Object object, java.lang.String actualParamName)
Wrap to aMapperMethod.ParamMap
if object isCollection
or array.- Parameters:
object
- a parameter objectactualParamName
- an actual parameter name (If specify a name, set an object toMapperMethod.ParamMap
with specified name)- Returns:
- a
MapperMethod.ParamMap
- Since:
- 3.5.5
-
-