org.springframework.boot.context.properties.bind

Class 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:
    of(Class), of(ResolvableType)
    • 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 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode 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.
        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
      • 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(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<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(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)

Copyright © 2019 Pivotal Software, Inc.. All rights reserved.