org.springframework.boot.context.properties.bind

Class BindResult<T>

  • java.lang.Object
    • org.springframework.boot.context.properties.bind.BindResult<T>
  • Type Parameters:
    T - the result type


    public final class BindResult<T>
    extends java.lang.Object
    A container object to return the result of a Binder bind operation. May contain either a successfully bound object or an empty result.
    Since:
    2.0.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object obj) 
      T get()
      Return the object that was bound or throw a NoSuchElementException if no value was bound.
      int hashCode() 
      void ifBound(java.util.function.Consumer<? super T> consumer)
      Invoke the specified consumer with the bound value, or do nothing if no value has been bound.
      boolean isBound()
      Returns true if a result was bound.
      <U> BindResult<U> map(java.util.function.Function<? super T,? extends U> mapper)
      Apply the provided mapping function to the bound value, or return an updated unbound result if no value has been bound.
      T orElse(T other)
      Return the object that was bound, or other if no value has been bound.
      T orElseGet(java.util.function.Supplier<? extends T> other)
      Return the object that was bound, or the result of invoking other if no value has been bound.
      <X extends java.lang.Throwable>
      T
      orElseThrow(java.util.function.Supplier<? extends X> exceptionSupplier)
      Return the object that was bound, or throw an exception to be created by the provided supplier if no value has been bound.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • get

        public T get()
              throws java.util.NoSuchElementException
        Return the object that was bound or throw a NoSuchElementException if no value was bound.
        Returns:
        the bound value (never null)
        Throws:
        java.util.NoSuchElementException - if no value was bound
        See Also:
        isBound()
      • isBound

        public boolean isBound()
        Returns true if a result was bound.
        Returns:
        if a result was bound
      • ifBound

        public void ifBound(java.util.function.Consumer<? super T> consumer)
        Invoke the specified consumer with the bound value, or do nothing if no value has been bound.
        Parameters:
        consumer - block to execute if a value has been bound
      • map

        public <U> BindResult<U> map(java.util.function.Function<? super T,? extends U> mapper)
        Apply the provided mapping function to the bound value, or return an updated unbound result if no value has been bound.
        Type Parameters:
        U - the type of the result of the mapping function
        Parameters:
        mapper - a mapping function to apply to the bound value. The mapper will not be invoked if no value has been bound.
        Returns:
        an BindResult describing the result of applying a mapping function to the value of this BindResult.
      • orElse

        public T orElse(T other)
        Return the object that was bound, or other if no value has been bound.
        Parameters:
        other - the value to be returned if there is no bound value (may be null)
        Returns:
        the value, if bound, otherwise other
      • orElseGet

        public T orElseGet(java.util.function.Supplier<? extends T> other)
        Return the object that was bound, or the result of invoking other if no value has been bound.
        Parameters:
        other - a Supplier of the value to be returned if there is no bound value
        Returns:
        the value, if bound, otherwise the supplied other
      • orElseThrow

        public <X extends java.lang.Throwable> T orElseThrow(java.util.function.Supplier<? extends X> exceptionSupplier)
                                                      throws X extends java.lang.Throwable
        Return the object that was bound, or throw an exception to be created by the provided supplier if no value has been bound.
        Type Parameters:
        X - the type of the exception to be thrown
        Parameters:
        exceptionSupplier - the supplier which will return the exception to be thrown
        Returns:
        the present value
        Throws:
        X - if there is no value present
        X extends java.lang.Throwable
      • 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