Class TypedStringValue
java.lang.Object
org.springframework.beans.factory.config.TypedStringValue
- All Implemented Interfaces:
BeanMetadataElement
Holder for a typed String value. Can be added to bean definitions
in order to explicitly specify a target type for a String value,
for example for collection elements.
This holder will just store the String value and the target type. The actual conversion will be performed by the bean factory.
- Since:
- 1.2
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTypedStringValue(String value) Create a newTypedStringValuefor the given String value.TypedStringValue(String value, Class<?> targetType) Create a newTypedStringValuefor the given String value and target type.TypedStringValue(String value, String targetTypeName) Create a newTypedStringValuefor the given String value and target type. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn the configuration sourceObjectfor this metadata element (may benull).Return the type name as actually specified for this particular value, if any.Class<?>Return the type to convert to.Return the type to convert to.getValue()Return the String value.inthashCode()booleanReturn whether this typed String value carries a target type .booleanReturn whether this value has been marked as dynamic.Class<?>resolveTargetType(ClassLoader classLoader) Determine the type to convert to, resolving it from a specified class name if necessary.voidMark this value as dynamic, i.e.voidSet the configuration sourceObjectfor this metadata element.voidsetSpecifiedTypeName(String specifiedTypeName) Set the type name as actually specified for this particular value, if any.voidsetTargetType(Class<?> targetType) Set the type to convert to.voidsetTargetTypeName(String targetTypeName) Specify the type to convert to.voidSet the String value.toString()
-
Constructor Details
-
TypedStringValue
Create a newTypedStringValuefor the given String value.- Parameters:
value- the String value
-
TypedStringValue
Create a newTypedStringValuefor the given String value and target type.- Parameters:
value- the String valuetargetType- the type to convert to
-
TypedStringValue
Create a newTypedStringValuefor the given String value and target type.- Parameters:
value- the String valuetargetTypeName- the type to convert to
-
-
Method Details
-
setValue
Set the String value.Only necessary for manipulating a registered value, for example in BeanFactoryPostProcessors.
-
getValue
Return the String value. -
setTargetType
Set the type to convert to.Only necessary for manipulating a registered value, for example in BeanFactoryPostProcessors.
-
getTargetType
Return the type to convert to. -
setTargetTypeName
Specify the type to convert to. -
getTargetTypeName
Return the type to convert to. -
hasTargetType
public boolean hasTargetType()Return whether this typed String value carries a target type . -
resolveTargetType
@Nullable public Class<?> resolveTargetType(@Nullable ClassLoader classLoader) throws ClassNotFoundException Determine the type to convert to, resolving it from a specified class name if necessary. Will also reload a specified Class from its name when called with the target type already resolved.- Parameters:
classLoader- the ClassLoader to use for resolving a (potential) class name- Returns:
- the resolved type to convert to
- Throws:
ClassNotFoundException- if the type cannot be resolved
-
setSource
Set the configuration sourceObjectfor this metadata element.The exact type of the object will depend on the configuration mechanism used.
-
getSource
Description copied from interface:BeanMetadataElementReturn the configuration sourceObjectfor this metadata element (may benull).- Specified by:
getSourcein interfaceBeanMetadataElement
-
setSpecifiedTypeName
Set the type name as actually specified for this particular value, if any. -
getSpecifiedTypeName
Return the type name as actually specified for this particular value, if any. -
setDynamic
public void setDynamic()Mark this value as dynamic, i.e. as containing an expression and hence not being subject to caching. -
isDynamic
public boolean isDynamic()Return whether this value has been marked as dynamic. -
equals
-
hashCode
public int hashCode() -
toString
-