Class Bindable<T>
- java.lang.Object
- org.springframework.boot.context.properties.bind.Bindable<T>
- Type Parameters:
T
- the source type
public final class Bindable<T> extends Object
Source that can be bound by aBinder
.- Since:
- 2.0.0
- See Also:
of(Class)
,of(ResolvableType)
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
<A extends Annotation>
AgetAnnotation(Class<A> type)
Return a single associated annotations that could affect binding.Annotation[]
getAnnotations()
Return any associated annotations that could affect binding.org.springframework.core.ResolvableType
getBoxedType()
Return the boxed type of the item to bind.org.springframework.core.ResolvableType
getType()
Return the type of the item to bind.Supplier<T>
getValue()
Return a supplier that provides the object value ornull
.int
hashCode()
static <E> Bindable<List<E>>
listOf(Class<E> elementType)
static <K,V>
Bindable<Map<K,V>>mapOf(Class<K> keyType, Class<V> valueType)
static <T> Bindable<T>
of(Class<T> type)
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.static <E> Bindable<Set<E>>
setOf(Class<E> elementType)
String
toString()
Bindable<T>
withAnnotations(Annotation... annotations)
Create an updatedBindable
instance with the specified annotations.Bindable<T>
withExistingValue(T existingValue)
Create an updatedBindable
instance with an existing value.Bindable<T>
withSuppliedValue(Supplier<T> suppliedValue)
Create an updatedBindable
instance with a value supplier.
Method Detail
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
public Supplier<T> getValue()
Return a supplier that provides the object value ornull
.- Returns:
- the value or
null
getAnnotations
public Annotation[] getAnnotations()
Return any associated annotations that could affect binding.- Returns:
- the associated annotations
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> type)
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
withAnnotations
public Bindable<T> withAnnotations(Annotation... annotations)
Create an updatedBindable
instance with the specified annotations.- Parameters:
annotations
- the annotations- Returns:
- an updated
Bindable
withExistingValue
public Bindable<T> withExistingValue(T existingValue)
Create an updatedBindable
instance with an existing value.- Parameters:
existingValue
- the existing value- Returns:
- an updated
Bindable
withSuppliedValue
public Bindable<T> withSuppliedValue(Supplier<T> suppliedValue)
Create an updatedBindable
instance with a value supplier.- Parameters:
suppliedValue
- the supplier for the value- Returns:
- an updated
Bindable
ofInstance
public 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.- Type Parameters:
T
- the source type- Parameters:
instance
- the instance (must not benull
)- Returns:
- a
Bindable
instance - See Also:
of(ResolvableType)
,withExistingValue(Object)
of
public static <T> Bindable<T> of(Class<T> type)
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:
of(ResolvableType)
listOf
public static <E> Bindable<List<E>> listOf(Class<E> elementType)
- Type Parameters:
E
- the element type- Parameters:
elementType
- the list element type- Returns:
- a
Bindable
instance
setOf
public static <E> Bindable<Set<E>> setOf(Class<E> elementType)
- Type Parameters:
E
- the element type- Parameters:
elementType
- the set element type- Returns:
- a
Bindable
instance
mapOf
public static <K,V> Bindable<Map<K,V>> mapOf(Class<K> keyType, Class<V> valueType)
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
keyType
- the map key typevalueType
- the map value type- Returns:
- a
Bindable
instance