public final class PropertyMapper extends ObjectSE
@ConfigurationProperties
からサードパーティのクラスにマッピングするときに役立つことを目的としています。述語に基づいて値をフィルタリングし、必要に応じて値を適合させることができます。例:
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);
マッピングは、最終的に setter
に適用したり、method call
をトリガーしたり、new instance
を作成したりできます。
修飾子と型 | クラスと説明 |
---|---|
static class | PropertyMapper.Source<T> マップ中のソース。 |
static interface | PropertyMapper.SourceOperator PropertyMapper.Source に適用できる操作。 |
修飾子と型 | メソッドと説明 |
---|---|
PropertyMapper | alwaysApplying(PropertyMapper.SourceOperator operator) 指定された PropertyMapper.SourceOperator をすべてのソースに適用する新しい PropertyMapper インスタンスを返します。 |
PropertyMapper | alwaysApplyingWhenNonNull() すべてのソースに whenNonNull を適用する新しい PropertyMapper インスタンスを返します。 |
<T> PropertyMapper.Source<T> | from(SupplierSE<T> supplier) マッピングの実行に使用できる指定された値サプライヤーから新しい PropertyMapper.Source を返します。 |
<T> PropertyMapper.Source<T> | from(T value) マッピングの実行に使用できる指定された値から新しい PropertyMapper.Source を返します。 |
static PropertyMapper | get() プロパティマッパーを返します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public PropertyMapper alwaysApplyingWhenNonNull()
whenNonNull
を適用する新しい PropertyMapper
インスタンスを返します。public PropertyMapper alwaysApplying(PropertyMapper.SourceOperator operator)
PropertyMapper.SourceOperator
をすべてのソースに適用する新しい PropertyMapper
インスタンスを返します。operator
- 適用するソース演算子 public <T> PropertyMapper.Source<T> from(SupplierSE<T> supplier)
PropertyMapper.Source
を返します。T
- ソース型 supplier
- 価値サプライヤー PropertyMapper.Source
from(Object)
public <T> PropertyMapper.Source<T> from(T value)
PropertyMapper.Source
を返します。T
- ソース型 value
- 値 PropertyMapper.Source
public static PropertyMapper get()