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 a Binder.
Since:
2.0.0
Author:
Phillip Webb, Madhura Bhave
See Also:
  • Method Details

    • getType

      public ResolvableType getType()
      Return the type of the item to bind.
      Returns:
      the type being bound
    • getBoxedType

      public 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 or null.
      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
    • hasBindRestriction

      public boolean hasBindRestriction(Bindable.BindRestriction bindRestriction)
      Returns true 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

      public BindMethod getBindMethod()
      Returns the method to be used to bind this bindable, or null if no specific binding method is required.
      Returns:
      the bind method or null
      Since:
      3.0.8
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withAnnotations

      public Bindable<T> withAnnotations(Annotation... annotations)
      Create an updated Bindable instance with the specified annotations.
      Parameters:
      annotations - the annotations
      Returns:
      an updated Bindable
    • withExistingValue

      public Bindable<T> withExistingValue(T existingValue)
      Create an updated Bindable instance with an existing value. Implies that Java Bean binding will be used.
      Parameters:
      existingValue - the existing value
      Returns:
      an updated Bindable
    • withSuppliedValue

      public Bindable<T> withSuppliedValue(Supplier<T> suppliedValue)
      Create an updated Bindable instance with a value supplier.
      Parameters:
      suppliedValue - the supplier for the value
      Returns:
      an updated Bindable
    • withBindRestrictions

      public Bindable<T> withBindRestrictions(Bindable.BindRestriction... additionalRestrictions)
      Create an updated Bindable instance with additional bind restrictions.
      Parameters:
      additionalRestrictions - any additional restrictions to apply
      Returns:
      an updated Bindable
      Since:
      2.5.0
    • withBindMethod

      public Bindable<T> withBindMethod(BindMethod bindMethod)
      Create an updated Bindable instance with a specific bind method. To use value 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

      public static <T> Bindable<T> ofInstance(T instance)
      Create a new Bindable 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 be null)
      Returns:
      a Bindable instance
      See Also:
    • of

      public static <T> Bindable<T> of(Class<T> type)
      Create a new Bindable of the specified type.
      Type Parameters:
      T - the source type
      Parameters:
      type - the type (must not be null)
      Returns:
      a Bindable instance
      See Also:
    • listOf

      public static <E> Bindable<List<E>> listOf(Class<E> elementType)
      Create a new Bindable List of the specified element type.
      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)
      Create a new Bindable Set of the specified element type.
      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)
      Create a new Bindable Map of the specified key and value type.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      keyType - the map key type
      valueType - the map value type
      Returns:
      a Bindable instance
    • of

      public static <T> Bindable<T> of(ResolvableType type)
      Create a new Bindable of the specified type.
      Type Parameters:
      T - the source type
      Parameters:
      type - the type (must not be null)
      Returns:
      a Bindable instance
      See Also: