public abstract class AbstractFilter<T> extends Object implements Filter<T>
null
candidate values from non-null
ones, and delegates processing to concrete subclass implementations. Also, this AbstractFilter
implementation provides a standard for emitting Filter debug statements (i.e. for toString() calls).Modifier and Type | Field and Description |
---|---|
protected org.apache.maven.plugin.logging.Log |
log |
protected static String |
TOSTRING_INDENT
Initial-line indent for human-readable toString() rendering.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractFilter()
Convenience constructor which creates an AbstractFilter which does not process null values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(T candidate)
Method that is invoked to determine if a candidate instance should be accepted or not.
|
protected void |
addDelayedLogMessage(String logLevel,
String message)
Adds a log message to be emitted when this AbstractFilter is initialized (and the Log is made available to it).
|
void |
initialize(org.apache.maven.plugin.logging.Log log)
Initializes this Filter, and assigns the supplied Log for use by this Filter.
|
boolean |
isInitialized() |
protected abstract boolean |
onCandidate(T nonNullCandidate)
Method that is invoked to determine if a candidate instance should be accepted or not.
|
protected void |
onInitialize()
Override this method to perform some custom action after standard initialization is complete.
|
protected boolean |
onNullCandidate()
Override this to perform an action other than debug logging whenever this AbstractFilter
receives a null candidate.
|
protected void |
setProcessNullValues(boolean processNullValues)
Assigns the
processNullValues property which indicates if this AbstractFilter
should process null values or not. |
String |
toString() |
protected void |
validateDiSetterCalledBeforeInitialization(String setterPropertyName)
Validator method which should be called in a DI setter method to ensure that this AbstractFilter has
not yet been initialized.
|
protected static final String TOSTRING_INDENT
protected org.apache.maven.plugin.logging.Log log
protected AbstractFilter()
protected final void validateDiSetterCalledBeforeInitialization(String setterPropertyName)
setterPropertyName
- The name of the property to inject.protected final void addDelayedLogMessage(String logLevel, String message)
logLevel
- The logLevel of the message to emit.message
- The message to emit.protected final void setProcessNullValues(boolean processNullValues)
processNullValues
property which indicates if this AbstractFilter
should process null values or not.processNullValues
- true
to indicate that this AbstractFilter should process null values.public final void initialize(org.apache.maven.plugin.logging.Log log)
initialize
in interface Filter<T>
log
- The non-null Log which should be used by this Filter to emit log messages.public boolean isInitialized()
isInitialized
in interface Filter<T>
true
if this Filter has been properly initialized (by a call to the initialize
method).protected void onInitialize()
public final boolean accept(T candidate) throws IllegalStateException
Method that is invoked to determine if a candidate instance should be accepted or not.
Implementing classes should be prepared to handle null
candidate objects.
accept
in interface Filter<T>
candidate
- The candidate that should be tested for acceptance by this Filter.true
if the candidate is accepted by this Filter and false
otherwise.IllegalStateException
- if this Filter is not initialized by a call to the
initialize method before calling this matchAtLeastOnce method.protected boolean onNullCandidate()
false
. There is no point in calling super.onNullCandidate()
whenever this method is
overridden.false
- implying that AbstractFilters will not matchAtLeastOnce null
s by default.protected abstract boolean onCandidate(T nonNullCandidate)
Method that is invoked to determine if a candidate instance should be accepted or not.
nonNullCandidate
- The candidate that should be tested for acceptance by this Filter. Never null.true
if the candidate is accepted by this Filter and false
otherwise.Copyright © 2005–2017 MojoHaus. All rights reserved.