org.springframework.boot.context.properties.bind

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 java.lang.Object
    Source that can be bound by a Binder.
    Since:
    2.0.0
    See Also:
    of(Class), of(ResolvableType)
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  Bindable.BindRestriction
      Restrictions that can be applied when binding values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object obj) 
      <A extends java.lang.annotation.Annotation>
      A
      getAnnotation(java.lang.Class<A> type)
      Return a single associated annotations that could affect binding.
      java.lang.annotation.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.
      java.util.function.Supplier<T> getValue()
      Return a supplier that provides the object value or null.
      boolean hasBindRestriction(Bindable.BindRestriction bindRestriction)
      Returns true if the specified bind restriction has been added.
      int hashCode() 
      static <E> Bindable<java.util.List<E>> listOf(java.lang.Class<E> elementType)
      Create a new Bindable List of the specified element type.
      static <K,V> Bindable<java.util.Map<K,V>> mapOf(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
      Create a new Bindable Map of the specified key and value type.
      static <T> Bindable<T> of(java.lang.Class<T> type)
      Create a new Bindable of the specified type.
      static <T> Bindable<T> of(org.springframework.core.ResolvableType type)
      Create a new Bindable of the specified type.
      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.
      static <E> Bindable<java.util.Set<E>> setOf(java.lang.Class<E> elementType)
      Create a new Bindable Set of the specified element type.
      java.lang.String toString() 
      Bindable<T> withAnnotations(java.lang.annotation.Annotation... annotations)
      Create an updated Bindable instance with the specified annotations.
      Bindable<T> withBindRestrictions(Bindable.BindRestriction... additionalRestrictions)
      Create an updated Bindable instance with additional bind restrictions.
      Bindable<T> withExistingValue(T existingValue)
      Create an updated Bindable instance with an existing value.
      Bindable<T> withSuppliedValue(java.util.function.Supplier<T> suppliedValue)
      Create an updated Bindable instance with a value supplier.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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 java.util.function.Supplier<T> getValue()
        Return a supplier that provides the object value or null.
        Returns:
        the value or null
      • getAnnotations

        public java.lang.annotation.Annotation[] getAnnotations()
        Return any associated annotations that could affect binding.
        Returns:
        the associated annotations
      • getAnnotation

        public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.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
      • equals

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

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

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

        public Bindable<T> withAnnotations(java.lang.annotation.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.
        Parameters:
        existingValue - the existing value
        Returns:
        an updated Bindable
      • withSuppliedValue

        public Bindable<T> withSuppliedValue(java.util.function.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
      • 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(ResolvableType), withExistingValue(Object)
      • of

        public static <T> Bindable<T> of(java.lang.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:
        of(ResolvableType)
      • listOf

        public static <E> Bindable<java.util.List<E>> listOf(java.lang.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<java.util.Set<E>> setOf(java.lang.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<java.util.Map<K,V>> mapOf(java.lang.Class<K> keyType,
                                                               java.lang.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(org.springframework.core.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:
        of(Class)