net.sf.eos
Interface Predicate<T>

Type Parameters:
T - the value type
All Known Implementing Classes:
ConfigurationKey.AlwaysTruePredicate

@Experimental
public interface Predicate<T>

Represents a Predicate, that is, a function with one argument returning a boolean value. It not extends function since implementing this would entail changing the signature of the Function.apply(F) method to return a Boolean instead of a boolean, which would in turn allow people to return null from their predicate, which would in turn enable code that looks like if (myPredicate.apply(myObject)) ... to throw a NullPointerException.

Note: experimental - inspired by guice

Since:
0.1.0
Author:
Sascha Kohlmann

Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is equal to this Predicate.
 boolean evaluate(T value)
          Evaluates this predicate for the given value.
 

Method Detail

evaluate

boolean evaluate(@Nullable
                 T value)
Evaluates this predicate for the given value.

Parameters:
value - a value to be evaluated; should not be changed.
Returns:
a boolean value.

equals

boolean equals(Object obj)
Indicates whether some other object is equal to this Predicate. This method can return true only if the specified object is also a Predicate and, for every input object o, it returns exactly the same value. Thus, predicate1.equals(predicate2) implies that either predicate1.apply(o) and predicate2.apply(o) are both true, or both false.

Note that it is always safe not to override Object.equals(Object).

Overrides:
equals in class Object


Copyright © 2008. All Rights Reserved.