Class ConstructorArgumentValues
Supports values for a specific index in the constructor argument list as well as for generic argument matches by type.
- Since:
- 09.11.2003
- Author:
- Juergen Hoeller
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classHolder for a constructor argument value, with an optional type attribute indicating the target type of the actual constructor argument.
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new empty ConstructorArgumentValues object.Deep copy constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidCopy all given argument values into this object, using separate holder instances to keep the values independent from the original object.voidaddGenericArgumentValue(Object value) Add a generic argument value to be matched by type.voidaddGenericArgumentValue(Object value, String type) Add a generic argument value to be matched by type.voidAdd a generic argument value to be matched by type or name (if available).voidaddIndexedArgumentValue(int index, Object value) Add an argument value for the given index in the constructor argument list.voidaddIndexedArgumentValue(int index, Object value, String type) Add an argument value for the given index in the constructor argument list.voidaddIndexedArgumentValue(int index, ConstructorArgumentValues.ValueHolder newValue) Add an argument value for the given index in the constructor argument list.voidclear()Clear this holder, removing all argument values.booleanintReturn the number of argument values held in this instance, counting both indexed and generic argument values.getArgumentValue(int index, Class<?> requiredType) Look for an argument value that either corresponds to the given index in the constructor argument list or generically matches by type.getArgumentValue(int index, Class<?> requiredType, String requiredName) Look for an argument value that either corresponds to the given index in the constructor argument list or generically matches by type.getArgumentValue(int index, Class<?> requiredType, String requiredName, Set<ConstructorArgumentValues.ValueHolder> usedValueHolders) Look for an argument value that either corresponds to the given index in the constructor argument list or generically matches by type.getGenericArgumentValue(Class<?> requiredType) Look for a generic argument value that matches the given type.getGenericArgumentValue(Class<?> requiredType, String requiredName) Look for a generic argument value that matches the given type.getGenericArgumentValue(Class<?> requiredType, String requiredName, Set<ConstructorArgumentValues.ValueHolder> usedValueHolders) Look for the next generic argument value that matches the given type, ignoring argument values that have already been used in the current resolution process.Return the list of generic argument values.getIndexedArgumentValue(int index, Class<?> requiredType) Get argument value for the given index in the constructor argument list.getIndexedArgumentValue(int index, Class<?> requiredType, String requiredName) Get argument value for the given index in the constructor argument list.Return the map of indexed argument values.inthashCode()booleanhasIndexedArgumentValue(int index) Check whether an argument value has been registered for the given index.booleanisEmpty()Return if this holder does not contain any argument values, neither indexed ones nor generic ones.
- 
Constructor Details- 
ConstructorArgumentValuespublic ConstructorArgumentValues()Create a new empty ConstructorArgumentValues object.
- 
ConstructorArgumentValuesDeep copy constructor.- Parameters:
- original- the ConstructorArgumentValues to copy
 
 
- 
- 
Method Details- 
addArgumentValuesCopy all given argument values into this object, using separate holder instances to keep the values independent from the original object.Note: Identical ValueHolder instances will only be registered once, to allow for merging and re-merging of argument value definitions. Distinct ValueHolder instances carrying the same content are of course allowed. 
- 
addIndexedArgumentValueAdd an argument value for the given index in the constructor argument list.- Parameters:
- index- the index in the constructor argument list
- value- the argument value
 
- 
addIndexedArgumentValueAdd an argument value for the given index in the constructor argument list.- Parameters:
- index- the index in the constructor argument list
- value- the argument value
- type- the type of the constructor argument
 
- 
addIndexedArgumentValueAdd an argument value for the given index in the constructor argument list.- Parameters:
- index- the index in the constructor argument list
- newValue- the argument value in the form of a ValueHolder
 
- 
hasIndexedArgumentValuepublic boolean hasIndexedArgumentValue(int index) Check whether an argument value has been registered for the given index.- Parameters:
- index- the index in the constructor argument list
 
- 
getIndexedArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getIndexedArgumentValue(int index, @Nullable Class<?> requiredType) Get argument value for the given index in the constructor argument list.- Parameters:
- index- the index in the constructor argument list
- requiredType- the type to match (can be- nullto match untyped values only)
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getIndexedArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getIndexedArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName) Get argument value for the given index in the constructor argument list.- Parameters:
- index- the index in the constructor argument list
- requiredType- the type to match (can be- nullto match untyped values only)
- requiredName- the type to match (can be- nullto match unnamed values only, or empty String to match any name)
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getIndexedArgumentValuesReturn the map of indexed argument values.- Returns:
- unmodifiable Map with Integer index as key and ValueHolder as value
- See Also:
 
- 
addGenericArgumentValueAdd a generic argument value to be matched by type.Note: A single generic argument value will just be used once, rather than matched multiple times. - Parameters:
- value- the argument value
 
- 
addGenericArgumentValueAdd a generic argument value to be matched by type.Note: A single generic argument value will just be used once, rather than matched multiple times. - Parameters:
- value- the argument value
- type- the type of the constructor argument
 
- 
addGenericArgumentValueAdd a generic argument value to be matched by type or name (if available).Note: A single generic argument value will just be used once, rather than matched multiple times. - Parameters:
- newValue- the argument value in the form of a ValueHolder- Note: Identical ValueHolder instances will only be registered once, to allow for merging and re-merging of argument value definitions. Distinct ValueHolder instances carrying the same content are of course allowed. 
 
- 
getGenericArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getGenericArgumentValue(Class<?> requiredType) Look for a generic argument value that matches the given type.- Parameters:
- requiredType- the type to match
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getGenericArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getGenericArgumentValue(Class<?> requiredType, String requiredName) Look for a generic argument value that matches the given type.- Parameters:
- requiredType- the type to match
- requiredName- the name to match
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getGenericArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getGenericArgumentValue(@Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ConstructorArgumentValues.ValueHolder> usedValueHolders) Look for the next generic argument value that matches the given type, ignoring argument values that have already been used in the current resolution process.- Parameters:
- requiredType- the type to match (can be- nullto find an arbitrary next generic argument value)
- requiredName- the name to match (can be- nullto not match argument values by name, or empty String to match any name)
- usedValueHolders- a Set of ValueHolder objects that have already been used in the current resolution process and should therefore not be returned again
- Returns:
- the ValueHolder for the argument, or nullif none found
 
- 
getGenericArgumentValuesReturn the list of generic argument values.- Returns:
- unmodifiable List of ValueHolders
- See Also:
 
- 
getArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getArgumentValue(int index, Class<?> requiredType) Look for an argument value that either corresponds to the given index in the constructor argument list or generically matches by type.- Parameters:
- index- the index in the constructor argument list
- requiredType- the parameter type to match
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getArgumentValue(int index, Class<?> requiredType, String requiredName) Look for an argument value that either corresponds to the given index in the constructor argument list or generically matches by type.- Parameters:
- index- the index in the constructor argument list
- requiredType- the parameter type to match
- requiredName- the parameter name to match
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getArgumentValue@Nullable public ConstructorArgumentValues.ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ConstructorArgumentValues.ValueHolder> usedValueHolders) Look for an argument value that either corresponds to the given index in the constructor argument list or generically matches by type.- Parameters:
- index- the index in the constructor argument list
- requiredType- the parameter type to match (can be- nullto find an untyped argument value)
- requiredName- the parameter name to match (can be- nullto find an unnamed argument value, or empty String to match any name)
- usedValueHolders- a Set of ValueHolder objects that have already been used in the current resolution process and should therefore not be returned again (allowing to return the next generic argument match in case of multiple generic argument values of the same type)
- Returns:
- the ValueHolder for the argument, or nullif none set
 
- 
getArgumentCountpublic int getArgumentCount()Return the number of argument values held in this instance, counting both indexed and generic argument values.
- 
isEmptypublic boolean isEmpty()Return if this holder does not contain any argument values, neither indexed ones nor generic ones.
- 
clearpublic void clear()Clear this holder, removing all argument values.
- 
equals
- 
hashCodepublic int hashCode()
 
-