类 PropertyMapper.Source<T>
- java.lang.Object
- org.springframework.boot.context.properties.PropertyMapper.Source<T>
- 类型参数:
T
- the source type
- 封闭类:
- PropertyMapper
public static final class PropertyMapper.Source<T> extends Object
A source that is in the process of being mapped.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 <R> PropertyMapper.Source<R>
as(Function<T,R> adapter)
Return an adapted version of the source changed via the given adapter function.<R extends Number>
PropertyMapper.Source<Integer>asInt(Function<T,R> adapter)
Return an adapted version of the source withInteger
type.void
to(Consumer<T> consumer)
Complete the mapping by passing any non-filtered value to the specified consumer.void
toCall(Runnable runnable)
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.PropertyMapper.Source<T>
when(Predicate<T> predicate)
Return a filtered version of the source that won't map values that don't match the given predicate.PropertyMapper.Source<T>
whenEqualTo(Object object)
Return a filtered version of the source that will only map values equal to the specifiedobject
.PropertyMapper.Source<T>
whenFalse()
Return a filtered version of the source that will only map values that arefalse
.PropertyMapper.Source<T>
whenHasText()
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.PropertyMapper.Source<T>
whenNonNull()
Return a filtered version of the source that won't map non-null values or suppliers that throw aNullPointerException
.PropertyMapper.Source<T>
whenNot(Predicate<T> predicate)
Return a filtered version of the source that won't map values that match the given predicate.PropertyMapper.Source<T>
whenTrue()
Return a filtered version of the source that will only map values that aretrue
.
方法详细资料
asInt
public <R extends Number> PropertyMapper.Source<Integer> asInt(Function<T,R> adapter)
Return an adapted version of the source withInteger
type.- 类型参数:
R
- the resulting type- 参数:
adapter
- an adapter to convert the current value to a number.- 返回:
- a new adapted source instance
as
public <R> PropertyMapper.Source<R> as(Function<T,R> adapter)
Return an adapted version of the source changed via the given adapter function.- 类型参数:
R
- the resulting type- 参数:
adapter
- the adapter to apply- 返回:
- a new adapted source instance
whenNonNull
public PropertyMapper.Source<T> whenNonNull()
Return a filtered version of the source that won't map non-null values or suppliers that throw aNullPointerException
.- 返回:
- a new filtered source instance
whenTrue
public PropertyMapper.Source<T> whenTrue()
Return a filtered version of the source that will only map values that aretrue
.- 返回:
- a new filtered source instance
whenFalse
public PropertyMapper.Source<T> whenFalse()
Return a filtered version of the source that will only map values that arefalse
.- 返回:
- a new filtered source instance
whenHasText
public PropertyMapper.Source<T> whenHasText()
Return a filtered version of the source that will only map values that have atoString()
containing actual text.- 返回:
- a new filtered source instance
whenEqualTo
public PropertyMapper.Source<T> whenEqualTo(Object object)
Return a filtered version of the source that will only map values equal to the specifiedobject
.- 参数:
object
- the object to match- 返回:
- a new filtered source instance
whenInstanceOf
public <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.- 类型参数:
R
- the target type- 参数:
target
- the target type to match- 返回:
- a new filtered source instance
whenNot
public PropertyMapper.Source<T> whenNot(Predicate<T> predicate)
Return a filtered version of the source that won't map values that match the given predicate.- 参数:
predicate
- the predicate used to filter values- 返回:
- a new filtered source instance
when
public PropertyMapper.Source<T> when(Predicate<T> predicate)
Return a filtered version of the source that won't map values that don't match the given predicate.- 参数:
predicate
- the predicate used to filter values- 返回:
- a new filtered source instance
to
public void to(Consumer<T> consumer)
Complete the mapping by passing any non-filtered value to the specified consumer.- 参数:
consumer
- the consumer that should accept the value if it's not been filtered
toInstance
public <R> R toInstance(Function<T,R> factory)
Complete the mapping by creating a new instance from the non-filtered value.- 类型参数:
R
- the resulting type- 参数:
factory
- the factory used to create the instance- 返回:
- the instance
- 抛出:
NoSuchElementException
- if the value has been filtered