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>
Allow source mapping to complete using methods that accept nulls.
- Since:
- 4.0.0
- Author:
- Phillip Webb, Artsiom Yudovin, Chris Bono, Moritz Halbritter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Adapter that support nullable values.static interface
PropertyMapper.Source.Always.Factory<T, R extends @Nullable Object>
Factory that supports nullable values.static interface
PropertyMapper.Source.Always.Mapper<R extends @Nullable Object, T>
Mapper that supports nullable values. -
Method Summary
Modifier and TypeMethodDescription<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.void
Complete the mapping by passing any non-filtered value to the specified consumer.<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.void
Complete the mapping by calling the specified method when the value has not been filtered.<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.
-
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
-
to
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, theinstance
parameter is returned unchanged. The method is designed to be used with immutable objects.- Type Parameters:
R
- the result type- Parameters:
instance
- the current instancemapper
- the mapping function- Returns:
- a new mapped instance or the original instance
-
toInstance
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
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
-