POJO to store a filename, its match pattern and its replacement string.
A checkAndReplace method is provided where you can simultaneously check if
the field matches this replacer and if the pattern matches your field value.
Create a FieldReplacer for a field.
Any pattern exceptions are caught within this constructor and the object is
marked inValid. The error will be logged. This prevents this caller from
attempting invalid replacements.
fieldName - the name of the source field to operate on. Required.
toFieldName - the name of the target field. Required.
pattern - the pattern the field must match. Required.
replacement - the replacement string
flags - the Pattern flags value, or null if no flags are needed
Return the replacement value for a field value.
This does not check for a matching field; the caller must decide if this
FieldReplacer should operate on this value by checking getFieldName().
The method returns the value with the replacement. If the value returned is
not different then eiher the pattern didn't match or the replacement was a
Return a replacement value for a field.
This is designed to fail fast and trigger a replacement only when
necessary. If this method returns null, either the field does not match or
the value does not match the pattern (or possibly the pattern is invalid).
So only if the method returns a non-null value will you need to replace the
value for the field.
fieldName - the name of the field you are checking
value - the value of the field you are checking
a replacement value. If null, either the field does not match or
the value does not match.