Package net.sf.colossus.util
Class NullCheckPredicate<T>
- java.lang.Object
-
- net.sf.colossus.util.NullCheckPredicate<T>
-
- Type Parameters:
T
- The type of objects to check.
- All Implemented Interfaces:
Predicate<T>
public class NullCheckPredicate<T> extends java.lang.Object implements Predicate<T>
A predicate checking objects on being the null object. This class can be used on its own, returning the boolean value given in its constructor for null values and its opposite for non-null values. In this casenew NullCheckPredicate(true)
creates a predicate checking for null values, andnew NullCheckPredicate(false)
creates one to check for values other than null. Alternatively subclasses can overwritematchesNonNullValue(Object)
, in which case that determines the value for the non-null objects.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
nullValue
-
Constructor Summary
Constructors Constructor Description NullCheckPredicate(boolean nullValue)
Creates a new predicate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
matches(T object)
Returns true iff the given object matches the predicate.protected boolean
matchesNonNullValue(T object)
Can be overwritten to apply further checks for values that are not null.
-
-
-
Method Detail
-
matches
public final boolean matches(T object)
Description copied from interface:Predicate
Returns true iff the given object matches the predicate. Note that null values are allowed and implementers are to return either true or false for them instead of throwing exceptions.
-
matchesNonNullValue
protected boolean matchesNonNullValue(T object)
Can be overwritten to apply further checks for values that are not null.- Parameters:
object
- The value to check. Not null.- Returns:
- True iff the object matches. In the default implementation the opposite of the null value.
-
-