Class Bindable<T>
java.lang.Object
org.springframework.boot.context.properties.bind.Bindable<T>
- Type Parameters:
T
- the source type
Source that can be bound by a
Binder
.- Since:
- 2.0.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Restrictions that can be applied when binding values. -
Method Summary
Modifier and TypeMethodDescriptionboolean
<A extends Annotation>
AgetAnnotation
(Class<A> type) Return a single associated annotations that could affect binding.Return any associated annotations that could affect binding.Returns themethod
to be used to bind this bindable, ornull
if no specific binding method is required.org.springframework.core.ResolvableType
Return the boxed type of the item to bind.org.springframework.core.ResolvableType
getType()
Return the type of the item to bind.getValue()
Return a supplier that provides the object value ornull
.boolean
hasBindRestriction
(Bindable.BindRestriction bindRestriction) Returnstrue
if the specified bind restriction has been added.int
hashCode()
static <T> Bindable<T>
Create a newBindable
of the specified type.static <T> Bindable<T>
of
(org.springframework.core.ResolvableType type) Create a newBindable
of the specified type.static <T> Bindable<T>
ofInstance
(T instance) Create a newBindable
of the type of the specified instance with an existing value equal to the instance.toString()
withAnnotations
(Annotation... annotations) Create an updatedBindable
instance with the specified annotations.withBindMethod
(BindMethod bindMethod) Create an updatedBindable
instance with a specific bind method.withBindRestrictions
(Bindable.BindRestriction... additionalRestrictions) Create an updatedBindable
instance with additional bind restrictions.withExistingValue
(T existingValue) Create an updatedBindable
instance with an existing value.withSuppliedValue
(Supplier<T> suppliedValue) Create an updatedBindable
instance with a value supplier.
-
Method Details
-
getType
public org.springframework.core.ResolvableType getType()Return the type of the item to bind.- Returns:
- the type being bound
-
getBoxedType
public org.springframework.core.ResolvableType getBoxedType()Return the boxed type of the item to bind.- Returns:
- the boxed type for the item being bound
-
getValue
Return a supplier that provides the object value ornull
.- Returns:
- the value or
null
-
getAnnotations
Return any associated annotations that could affect binding.- Returns:
- the associated annotations
-
getAnnotation
Return a single associated annotations that could affect binding.- Type Parameters:
A
- the annotation type- Parameters:
type
- annotation type- Returns:
- the associated annotation or
null
-
hasBindRestriction
Returnstrue
if the specified bind restriction has been added.- Parameters:
bindRestriction
- the bind restriction to check- Returns:
- if the bind restriction has been added
- Since:
- 2.5.0
-
getBindMethod
Returns themethod
to be used to bind this bindable, ornull
if no specific binding method is required.- Returns:
- the bind method or
null
- Since:
- 3.0.8
-
equals
-
hashCode
public int hashCode() -
toString
-
withAnnotations
Create an updatedBindable
instance with the specified annotations.- Parameters:
annotations
- the annotations- Returns:
- an updated
Bindable
-
withExistingValue
Create an updatedBindable
instance with an existing value. Implies that Java Bean binding will be used.- Parameters:
existingValue
- the existing value- Returns:
- an updated
Bindable
-
withSuppliedValue
Create an updatedBindable
instance with a value supplier.- Parameters:
suppliedValue
- the supplier for the value- Returns:
- an updated
Bindable
-
withBindRestrictions
Create an updatedBindable
instance with additional bind restrictions.- Parameters:
additionalRestrictions
- any additional restrictions to apply- Returns:
- an updated
Bindable
- Since:
- 2.5.0
-
withBindMethod
Create an updatedBindable
instance with a specific bind method. To usevalue object binding
, the current instance must not have an existing or supplied value.- Parameters:
bindMethod
- the method to use to bind the bindable- Returns:
- an updated
Bindable
- Since:
- 3.0.8
-
ofInstance
Create a newBindable
of the type of the specified instance with an existing value equal to the instance.- Type Parameters:
T
- the source type- Parameters:
instance
- the instance (must not benull
)- Returns:
- a
Bindable
instance - See Also:
-
of
Create a newBindable
of the specified type.- Type Parameters:
T
- the source type- Parameters:
type
- the type (must not benull
)- Returns:
- a
Bindable
instance - See Also:
-
listOf
- Type Parameters:
E
- the element type- Parameters:
elementType
- the list element type- Returns:
- a
Bindable
instance
-
setOf
- Type Parameters:
E
- the element type- Parameters:
elementType
- the set element type- Returns:
- a
Bindable
instance
-
mapOf
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
keyType
- the map key typevalueType
- the map value type- Returns:
- a
Bindable
instance
-
of
Create a newBindable
of the specified type.
-