Class PropertyMapper.Source<T>
java.lang.Object
org.springframework.boot.context.properties.PropertyMapper.Source<T>
- Type Parameters:
T
- the source type
- Enclosing class:
- PropertyMapper
A source that is in the process of being mapped.
-
Method Summary
Modifier and TypeMethodDescription<R> PropertyMapper.Source<R>
Return an adapted version of the source changed via the given adapter function.<R extends Number>
PropertyMapper.Source<Integer>Return an adapted version of the source withInteger
type.void
Complete the mapping by passing any non-filtered value to the specified consumer.<R> R
to
(R instance, BiFunction<R, T, R> 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
(Function<T, R> factory) Complete the mapping by creating a new instance from the non-filtered value.Return a filtered version of the source that won't map values that don't match the given predicate.whenEqualTo
(Object object) Return a filtered version of the source that will only map values equal to the specifiedobject
.Return a filtered version of the source that will only map values that arefalse
.Return a filtered version of the source that will only map values that have atoString()
containing actual text.<R extends T>
PropertyMapper.Source<R>whenInstanceOf
(Class<R> target) Return a filtered version of the source that will only map values that are an instance of the given type.Return a filtered version of the source that won't map non-null values or suppliers that throw aNullPointerException
.Return a filtered version of the source that won't map values that match the given predicate.whenTrue()
Return a filtered version of the source that will only map values that aretrue
.
-
Method Details
-
asInt
Return an adapted version of the source withInteger
type.- Type Parameters:
R
- the resulting type- Parameters:
adapter
- an adapter to convert the current value to a number.- Returns:
- a new adapted source instance
-
as
Return an adapted version of the source changed via the given adapter function.- Type Parameters:
R
- the resulting type- Parameters:
adapter
- the adapter to apply- Returns:
- a new adapted source instance
-
whenNonNull
Return a filtered version of the source that won't map non-null values or suppliers that throw aNullPointerException
.- Returns:
- a new filtered source instance
-
whenTrue
Return a filtered version of the source that will only map values that aretrue
.- Returns:
- a new filtered source instance
-
whenFalse
Return a filtered version of the source that will only map values that arefalse
.- Returns:
- a new filtered source instance
-
whenHasText
Return a filtered version of the source that will only map values that have atoString()
containing actual text.- Returns:
- a new filtered source instance
-
whenEqualTo
Return a filtered version of the source that will only map values equal to the specifiedobject
.- Parameters:
object
- the object to match- Returns:
- a new filtered source instance
-
whenInstanceOf
Return a filtered version of the source that will only map values that are an instance of the given type.- Type Parameters:
R
- the target type- Parameters:
target
- the target type to match- Returns:
- a new filtered source instance
-
whenNot
Return a filtered version of the source that won't map values that match the given predicate.- Parameters:
predicate
- the predicate used to filter values- Returns:
- a new filtered source instance
-
when
Return a filtered version of the source that won't map values that don't match the given predicate.- Parameters:
predicate
- the predicate used to filter values- Returns:
- a new filtered source instance
-
to
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
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
- Since:
- 3.0.0
-
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
-