A
- The algorithm data typeD
- The underlying data typepublic interface TypeAdapter<A,D>
MaskingAlgorithm.MaskingType
, while the possible
underlying types are enumerated in UnderlyingDataType
.
Each type adapter class implements a pair of type conversions. As each value to be masked
requires a new TypeAdapter, a TypeAdapterFactory
is typically used to create them. That
class also maintains a list of available adapters classes.
If a type conversion cannot be performed because the underlying value is empty or all-whitespace, the adapter should return null in underlyingToAlgorithm, but substitute the original empty value back in algorithmToUnderlying should the algorithm return null. This allows empty values to pass through unchanged, even when the algorithmType is not able to express such empty values. This is necessary, for example, when a Date algorithm is applied to String type underlying date.
Modifier and Type | Method and Description |
---|---|
D |
algorithmToUnderlying(A algorithmValue)
Convert an object from the algorithm type to the underlying type.
|
default void |
configure(MaskValueMetadata metadata)
Configure this type adapter.
|
default void |
configure(MaskValueMetadata metadata,
MaskingAlgorithm<A> algorithm)
Configure this adapter.
|
MaskingAlgorithm.MaskingType |
getAlgorithmType()
Get the algorithm type of this type adapter.
|
UnderlyingDataType |
getUnderlyingType()
Get the underlying type of this type adapter.
|
A |
underlyingToAlgorithm(D underlyingValue)
Convert an object from the underlying type to the algorithm type.
|
MaskingAlgorithm.MaskingType getAlgorithmType()
UnderlyingDataType getUnderlyingType()
default void configure(MaskValueMetadata metadata)
metadata
- An interface providing methods to retrieve additional information about the
underlying typedefault void configure(MaskValueMetadata metadata, @Nullable MaskingAlgorithm<A> algorithm)
metadata
- An interface providing methods to retrieve additional information about the
underlying typealgorithm
- An algorithm instance this adapter is instantiated forD algorithmToUnderlying(A algorithmValue) throws PostMaskTypeConversionException
algorithmValue
- An object of the type referenced by getAlgorithmTypePostMaskTypeConversionException
- If the type conversion failsA underlyingToAlgorithm(D underlyingValue) throws PreMaskTypeConversionException
underlyingValue
- An object of the type referenced by getUnderlyingTypePreMaskTypeConversionException
- If the type conversion fails