public class PredicateGroup extends Predicate implements java.util.List<Predicate>
PredicateGroup
is a Predicate
that represents a list
of Predicates
(following the composite pattern). This
allows to build predicate trees for reflecting complex queries that include
sub-terms.
The predicates in a group are by default all required to match, ie. they will
be combined with "AND" in a lower-level query language, which is indicated by
allRequired()
returning true. If setAllRequired(boolean)
is
called with false
, or if the parameter or
is set to
true
, the child predicates will be combined with "OR", ie. only
one must match for the whole group to match.
If the parameter not
is set to true
, the result of
this group will be negated. See also isNegated()
and
setNegated(boolean)
.
This class extends both the Predicate
class and implements the
List
interface, backed by a standard ArrayList
internally.
The standard type name for predicate groups is given by TYPE
(
), which is also used when using the default
constructor.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TYPE |
IGNORE_CASE, ORDER_BY, PARAM_CASE, PARAM_EXCERPT, PARAM_FACET_STRATEGY, PARAM_GUESS_TOTAL, PARAM_LIMIT, PARAM_OFFSET, PARAM_OPTIONS_INDEXTAG, PARAM_OPTIONS_TRAVERSAL, PARAM_SORT, SORT_ASCENDING, SORT_DESCENDING, TRAVERSAL_FAIL, TRAVERSAL_OK, TRAVERSAL_WARN
Constructor and Description |
---|
PredicateGroup()
Creates this predicate group with the group type
"group" , and a predicate name of null . |
PredicateGroup(java.lang.String name)
Creates this predicate group with the given name and the group type
"group" , using the
Predicate.Predicate(String, String) constructor. |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
Predicate element) |
boolean |
add(Predicate o) |
boolean |
addAll(java.util.Collection<? extends Predicate> c) |
boolean |
addAll(int index,
java.util.Collection<? extends Predicate> c) |
boolean |
allRequired()
Returns whether all predicates are combined with "AND", ie.
|
void |
clear() |
PredicateGroup |
clone()
Clones this predicate group so that the returned clone can be used
completely independently from this original.
|
PredicateGroup |
clone(boolean resetName)
Clones this predicate group so that the returned clone can be used
completely independently from this original.
|
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
static PredicateGroup |
create(java.util.Map predicateParameterMap)
Converts a map with predicates and their parameters into a predicate
tree.
|
boolean |
equals(java.lang.Object obj) |
Predicate |
get(int index) |
Predicate |
getByName(java.lang.String name)
Returns a certain predicate by its
name . |
Predicate |
getByPath(java.lang.String path)
Returns a certain predicate by its
path ,
relative to this predicate. |
int |
hashCode() |
int |
indexOf(java.lang.Object o) |
boolean |
isEmpty() |
boolean |
isNegated()
Returns whether the result of this predicate group should be negated.
|
java.util.Iterator<Predicate> |
iterator() |
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator<Predicate> |
listIterator() |
java.util.ListIterator<Predicate> |
listIterator(int index) |
Predicate |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
Predicate |
set(int index,
Predicate element) |
void |
setAllRequired(boolean all)
Sets whether all predicates are combined with "AND", ie.
|
void |
setNegated(boolean not)
Sets whether the result of this group should be negated.
|
int |
size() |
java.util.List<Predicate> |
subList(int fromIndex,
int toIndex) |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString()
Overwrites the standard
Object.toString() implementation and
returns a debug-friendly string including all sub predicates (via their
toString() method). |
java.lang.String |
toURL()
Returns an URL query part containing the given group.
|
get, get, getBool, getName, getParameters, getPath, getType, hasNonEmptyValue, ignored, set, setIgnored
public static final java.lang.String TYPE
public PredicateGroup()
"group"
, and a predicate name of null
.
Use this constructor when the name should be deducted automatically (see
Predicate.getName()
) or for the root group of a predicate tree, because
the name must be null
for that case.public PredicateGroup(java.lang.String name)
"group"
, using the
Predicate.Predicate(String, String)
constructor. If you create a
root group of a predicate tree, the name must be null
(you
can use the default constructor PredicateGroup()
for that).public static PredicateGroup create(java.util.Map predicateParameterMap)
public java.lang.String toURL()
#createMap(PredicateGroup)
and
#createPredicates(Map)
. For example, the returned value could be:
type=cq:Page&path=/content
. Note that this won't be a
complete URL, just a list of parameters for an URL query part. The keys
and values will be properly escaped for use in an URL.
public boolean allRequired()
true
(AND):true
for "AND" (default), false
for "OR"public void setAllRequired(boolean all)
all
- true
for "AND", false
for "OR"public boolean isNegated()
false
.true
for exclusive, false
for inclusive
(default)public void setNegated(boolean not)
not
- true
if the group should be negated,
false
if not (default)public Predicate getByName(java.lang.String name)
name
.public Predicate getByPath(java.lang.String path)
path
,
relative to this predicate.public PredicateGroup clone()
public PredicateGroup clone(boolean resetName)
clone
in class Predicate
resetName
- whether to reset the name and child predicate names to
null
so that they will be automatically
deducted (see Predicate.getName()
)public boolean equals(java.lang.Object obj)
public int hashCode()
public java.lang.String toString()
Object.toString()
implementation and
returns a debug-friendly string including all sub predicates (via their
toString()
method). The final string is
multi-lined and indented for easy readability of the inherent tree
structure.public boolean add(Predicate o)
public void add(int index, Predicate element)
add
in interface java.util.List<Predicate>
public boolean addAll(java.util.Collection<? extends Predicate> c)
public boolean addAll(int index, java.util.Collection<? extends Predicate> c)
addAll
in interface java.util.List<Predicate>
public void clear()
public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<Predicate>
public boolean isEmpty()
public java.util.Iterator<Predicate> iterator()
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<Predicate>
public java.util.ListIterator<Predicate> listIterator()
listIterator
in interface java.util.List<Predicate>
public java.util.ListIterator<Predicate> listIterator(int index)
listIterator
in interface java.util.List<Predicate>
public boolean remove(java.lang.Object o)
public Predicate remove(int index)
remove
in interface java.util.List<Predicate>
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public Predicate set(int index, Predicate element)
set
in interface java.util.List<Predicate>
public int size()
public java.util.List<Predicate> subList(int fromIndex, int toIndex)
subList
in interface java.util.List<Predicate>
public java.lang.Object[] toArray()
Copyright © 2010 - 2020 Adobe. All Rights Reserved