类 PropertyMapper
java.lang.Object
cn.taketoday.util.PropertyMapper
Utility that can be used to map values from a supplied source to a destination.
Can filter values based on predicates and adapt values if needed. For example:
PropertyMapper map = PropertyMapper.get(); map.from(source::getName) .to(destination::setName); map.from(source::getTimeout) .whenNonNull() .asInt(Duration::getSeconds) .to(destination::setTimeoutSecs); map.from(source::isEnabled) .whenFalse(). .toCall(destination::disable);
Mappings can ultimately be applied to a setter, trigger a
method call or create a
new instance.
- 从以下版本开始:
- 4.0 2022/1/16 17:01
- 作者:
- Phillip Webb, Artsiom Yudovin, Harry Yang
-
嵌套类概要
嵌套类修饰符和类型类说明private static final recordSupplier that will catch and ignore anyNullPointerException.static final classA source that is in the process of being mapped.static interfaceAn operation that can be applied to aPropertyMapper.Source. -
字段概要
字段修饰符和类型字段说明private static final Predicate<?>private static final PropertyMapperprivate final PropertyMapperprivate final PropertyMapper.SourceOperator -
构造器概要
构造器限定符构造器说明privatePropertyMapper(PropertyMapper parent, PropertyMapper.SourceOperator sourceOperator) -
方法概要
修饰符和类型方法说明alwaysApplying(PropertyMapper.SourceOperator operator) Return a newPropertyMapperinstance that applies the givenPropertyMapper.SourceOperatorto every source.Return a newPropertyMapperinstance that applieswhenNonNullto every source.<T> PropertyMapper.Source<T>Return a newPropertyMapper.Sourcefrom the specified value supplier that can be used to perform the mapping.<T> PropertyMapper.Source<T>from(T value) Return a newPropertyMapper.Sourcefrom the specified value that can be used to perform the mapping.static PropertyMapperget()Return the property mapper.private <T> PropertyMapper.Source<T>private <T> PropertyMapper.Source<T>whenNonNull(PropertyMapper.Source<T> source)
-
字段详细资料
-
ALWAYS
-
INSTANCE
-
parent
-
sourceOperator
-
-
构造器详细资料
-
PropertyMapper
private PropertyMapper(@Nullable PropertyMapper parent, @Nullable PropertyMapper.SourceOperator sourceOperator)
-
-
方法详细资料
-
alwaysApplyingWhenNonNull
Return a newPropertyMapperinstance that applieswhenNonNullto every source.- 返回:
- a new property mapper instance
-
whenNonNull
-
alwaysApplying
Return a newPropertyMapperinstance that applies the givenPropertyMapper.SourceOperatorto every source.- 参数:
operator- the source operator to apply- 返回:
- a new property mapper instance
-
from
Return a newPropertyMapper.Sourcefrom the specified value supplier that can be used to perform the mapping.- 类型参数:
T- the source type- 参数:
supplier- the value supplier- 返回:
- a
PropertyMapper.Sourcethat can be used to complete the mapping - 另请参阅:
-
from
Return a newPropertyMapper.Sourcefrom the specified value that can be used to perform the mapping.- 类型参数:
T- the source type- 参数:
value- the value- 返回:
- a
PropertyMapper.Sourcethat can be used to complete the mapping
-
getSource
-
get
Return the property mapper.- 返回:
- the property mapper
-