Package org.n52.janmayen.function
Class Predicates
- java.lang.Object
-
- org.n52.janmayen.function.Predicates
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Predicate<T>alwaysFalse()Creates a predicate that is alwaysfalse.static <T> Predicate<T>alwaysTrue()Creates a predicate that is alwaystrue.static <T> Predicate<T>constant(boolean value)Creates a predicate that returns a constant value.static <T,U>
Predicate<U>curryFirst(BiPredicate<T,U> predicate, T t)Curries the first parameter of theBiPredicateand creates aPredicate.static <T,U>
Predicate<T>currySecond(BiPredicate<T,U> predicate, U u)Curries the second parameter of theBiPredicateand creates aPredicate.static <T,U extends T>
Predicate<T>instanceOf(Class<? extends U> clazz)Creates aPredicatethat checks if it's input is an instance ofclazz.static <T> Predicate<T>not(Predicate<T> predicate)Negates the predicate.static <T> Predicate<T>of(Predicate<T> predicate)Creates a predicate.
-
-
-
Method Detail
-
not
public static <T> Predicate<T> not(Predicate<T> predicate)
Negates the predicate.- Type Parameters:
T- the type of the input to the predicate- Parameters:
predicate- the predicate to negate- Returns:
- the negated predicate
-
of
public static <T> Predicate<T> of(Predicate<T> predicate)
Creates a predicate.- Type Parameters:
T- the type of the input to the predicate- Parameters:
predicate- the predicate- Returns:
- the predicate
-
alwaysFalse
public static <T> Predicate<T> alwaysFalse()
Creates a predicate that is alwaysfalse.- Type Parameters:
T- the type of the input to the predicate- Returns:
- the predicate
-
alwaysTrue
public static <T> Predicate<T> alwaysTrue()
Creates a predicate that is alwaystrue.- Type Parameters:
T- the type of the input to the predicate- Returns:
- the predicate
-
constant
public static <T> Predicate<T> constant(boolean value)
Creates a predicate that returns a constant value.- Type Parameters:
T- the type of the input to the predicate- Parameters:
value- the constant value- Returns:
- the predicate
-
instanceOf
public static <T,U extends T> Predicate<T> instanceOf(@Nonnull Class<? extends U> clazz)
Creates aPredicatethat checks if it's input is an instance ofclazz.- Type Parameters:
T- The input type.U- The type of which the input has to be an instance of.- Parameters:
clazz- The class of which the input has to be an instance of.- Returns:
- The predicate.
-
curryFirst
public static <T,U> Predicate<U> curryFirst(@Nonnull BiPredicate<T,U> predicate, T t)
Curries the first parameter of theBiPredicateand creates aPredicate.- Type Parameters:
T- the first parameter typeU- the second parameter type- Parameters:
predicate- the predicatet- the curried parameter- Returns:
- the curried predicate
-
currySecond
public static <T,U> Predicate<T> currySecond(@Nonnull BiPredicate<T,U> predicate, U u)
Curries the second parameter of theBiPredicateand creates aPredicate.- Type Parameters:
T- the first parameter typeU- the second parameter type- Parameters:
predicate- the predicateu- the curried parameter- Returns:
- the curried predicate
-
-