Class OptionalPredicate
java.lang.Object
io.github.torand.fastersql.predicate.OptionalPredicate
Implements an optional predicate.
The predicate is only executed if the wrapped predicate is present.
-
Method Summary
Modifier and TypeMethodDescriptionand
(OptionalPredicate other) Creates an optional compound predicate of performing the boolean operator AND on this optional predicate and the specified optional predicate.Creates an optional compound predicate of performing the boolean operator AND on this optional predicate and the specified predicate.static OptionalPredicate
empty()
Creates an optional predicate with no wrapped predicate.get()
Gets the wrapped predicate if present.boolean
Indicates whether there is a wrapped predicate.static OptionalPredicate
Creates an optional predicate wrapping specified non-null predicate.static OptionalPredicate
ofNullable
(Predicate predicate) Creates an optional predicate wrapping specified null or non-null predicate.or
(OptionalPredicate other) Creates an optional compound predicate of performing the boolean operator OR on this optional predicate and the specified optional predicate.Creates an optional compound predicate of performing the boolean operator OR on this optional predicate and the specified predicate.stream()
Gets a stream containing the wrapped predicate, if any.static Collection
<Predicate> unwrap
(OptionalPredicate... optionalPredicates) Gets a list of present wrapped predicates from the specified array of optional predicates.
-
Method Details
-
of
Creates an optional predicate wrapping specified non-null predicate.- Parameters:
predicate
- the predicate.- Returns:
- the optional predicate.
-
ofNullable
Creates an optional predicate wrapping specified null or non-null predicate.- Parameters:
predicate
- the predicate.- Returns:
- the optional predicate.
-
empty
Creates an optional predicate with no wrapped predicate.- Returns:
- the optional predicate.
-
isPresent
public boolean isPresent()Indicates whether there is a wrapped predicate.- Returns:
- true if there is wrapped predicate; else false.
-
get
Gets the wrapped predicate if present. Throws if not present.- Returns:
- the wrapped predicate.
-
stream
Gets a stream containing the wrapped predicate, if any.- Returns:
- the stream.
-
or
Creates an optional compound predicate of performing the boolean operator OR on this optional predicate and the specified predicate.- Parameters:
other
- the other predicate.- Returns:
- the optional compound predicate.
-
or
Creates an optional compound predicate of performing the boolean operator OR on this optional predicate and the specified optional predicate.- Parameters:
other
- the other optional predicate.- Returns:
- the optional compound predicate.
-
and
Creates an optional compound predicate of performing the boolean operator AND on this optional predicate and the specified predicate.- Parameters:
other
- the other predicate.- Returns:
- the optional compound predicate.
-
and
Creates an optional compound predicate of performing the boolean operator AND on this optional predicate and the specified optional predicate.- Parameters:
other
- the other optional predicate.- Returns:
- the optional compound predicate.
-
unwrap
Gets a list of present wrapped predicates from the specified array of optional predicates.- Parameters:
optionalPredicates
- the optional predicates-- Returns:
- the collection of present predicates.
-