Class ConfigurableFieldSanitizer<T>
java.lang.Object
io.github.rabinarayanpatra.sanitizer.core.ConfigurableFieldSanitizer<T>
- Type Parameters:
T- the type of the field
- All Implemented Interfaces:
FieldSanitizer<T>
- Direct Known Subclasses:
TruncateSanitizer
Base class for sanitizers that accept configuration parameters.
Subclasses receive key-value parameters from the @Sanitize annotation
via configure(Map) before any sanitization calls. Parameters are
specified using the params attribute of @Sanitize:
@Sanitize(using = TruncateSanitizer.class, params = "maxLength=100") private String description;Multiple parameters can be separated by commas:
@Sanitize(using = MaskSanitizer.class, params = "reveal=6,character=X") private String accountNumber;
- Since:
- 1.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by the framework after instantiation to provide configuration parameters from the annotation.protected intgetIntParam(String key, int defaultValue) Returns a configuration parameter as an integer, or a default if not present or not parseable.protected StringReturns a configuration parameter value, or a default if not present.Returns the configuration parameters.parseParams(String paramString) Parses a comma-separatedkey=valueparameter string into a map.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.rabinarayanpatra.sanitizer.core.FieldSanitizer
sanitize
-
Constructor Details
-
ConfigurableFieldSanitizer
protected ConfigurableFieldSanitizer()Default constructor.
-
-
Method Details
-
configure
Called by the framework after instantiation to provide configuration parameters from the annotation.- Parameters:
params- the configuration key-value pairs; never null, may be empty
-
getParams
Returns the configuration parameters.- Returns:
- unmodifiable map of parameter key-value pairs
-
getParam
Returns a configuration parameter value, or a default if not present.- Parameters:
key- the parameter keydefaultValue- the default value if the key is absent- Returns:
- the parameter value or the default
-
getIntParam
Returns a configuration parameter as an integer, or a default if not present or not parseable.- Parameters:
key- the parameter keydefaultValue- the default value if the key is absent or invalid- Returns:
- the parameter value as int, or the default
-
parseParams
Parses a comma-separatedkey=valueparameter string into a map.- Parameters:
paramString- the raw parameter string from the annotation- Returns:
- a mutable map of parsed key-value pairs
-