Class PropertyMapper.Source.Always<T>

java.lang.Object
org.springframework.boot.context.properties.PropertyMapper.Source.Always<T>
Type Parameters:
T - the source type
Enclosing class:
PropertyMapper.Source<T>

public static class PropertyMapper.Source.Always<T> extends Object
Allow source mapping to complete using methods that accept nulls.
Since:
4.0.0
Author:
Phillip Webb, Artsiom Yudovin, Chris Bono, Moritz Halbritter
  • Method Details

    • as

      public <R> PropertyMapper.Source.Always<R> as(PropertyMapper.Source.Always.Adapter<? super T, ? extends R> adapter)
      Return an adapted version of the source changed through the given adapter function.
      Type Parameters:
      R - the resulting type
      Parameters:
      adapter - the adapter to apply
      Returns:
      a new adapted source instance
    • to

      public void to(Consumer<@Nullable ? super T> consumer)
      Complete the mapping by passing any non-filtered value to the specified consumer. The method is designed to be used with mutable objects.
      Parameters:
      consumer - the consumer that should accept the value if it's not been filtered
    • to

      public <R> R to(R instance, PropertyMapper.Source.Always.Mapper<R, ? super T> mapper)
      Complete the mapping for any non-filtered value by applying the given function to an existing instance and returning a new one. For filtered values, the instance parameter is returned unchanged. The method is designed to be used with immutable objects.
      Type Parameters:
      R - the result type
      Parameters:
      instance - the current instance
      mapper - the mapping function
      Returns:
      a new mapped instance or the original instance
    • toInstance

      public <R> R toInstance(PropertyMapper.Source.Always.Factory<? super T, ? extends R> factory)
      Complete the mapping by creating a new instance from the non-filtered value.
      Type Parameters:
      R - the resulting type
      Parameters:
      factory - the factory used to create the instance
      Returns:
      the instance
      Throws:
      NoSuchElementException - if the value has been filtered
    • toCall

      public void toCall(Runnable runnable)
      Complete the mapping by calling the specified method when the value has not been filtered.
      Parameters:
      runnable - the method to call if the value has not been filtered