Class Predicate<T>
- java.lang.Object
- 
- com.google.gerrit.index.query.Predicate<T>
 
- 
- Type Parameters:
- T- type of object the predicate can evaluate in memory.
 - Direct Known Subclasses:
- AndPredicate,- ApprovalPredicate,- IndexedQuery,- NotPredicate,- OperatorPredicate,- OrPredicate
 
 public abstract class Predicate<T> extends Object An abstract predicate tree for any form of query.Implementations should be immutable, such that the meaning of a predicate never changes once constructed. They should ensure their immutable promise by defensively copying any structures which might be modified externally, but was passed into the object's constructor. However, implementations may retain non-thread-safe caches internally, to speed up evaluation operations within the context of one thread's evaluation of the predicate. As a result, callers should assume predicates are not thread-safe, but that two predicate graphs produce the same results given the same inputs if they are equals(Object).Predicates should support deep inspection whenever possible, so that generic algorithms can be written to operate against them. Predicates which contain other predicates should override getChildren()to return the list of children nested within the predicate.
- 
- 
Constructor SummaryConstructors Constructor Description Predicate()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T> Predicate<T>and(Predicate<T>... that)Combine the passed predicates into a single AND node.static <T> Predicate<T>and(Collection<? extends Predicate<T>> that)Combine the passed predicates into a single AND node.static <T> Predicate<T>any()A predicate that matches any input, always, with no cost.Matchable<T>asMatchable()abstract Predicate<T>copy(Collection<? extends Predicate<T>> children)Create a copy of this predicate, with new children.abstract booleanequals(Object other)intestimateCost()Returns a cost estimate to run this predicate, higher figures cost more.Predicate<T>getChild(int i)Same asgetChildren().get(i)intgetChildCount()Same asgetChildren().size()List<Predicate<T>>getChildren()Get the children of this predicate, if any.List<Predicate<T>>getFlattenedPredicateList()Returns a list of this predicate and all its descendants.intgetLeafCount()Get the number of leaf terms in this predicate.StringgetPredicateString()abstract inthashCode()booleanisLeaf()booleanisMatchable()static <T> Predicate<T>not(Predicate<T> that)Invert the passed node.static <T> Predicate<T>or(Predicate<T>... that)Combine the passed predicates into a single OR node.static <T> Predicate<T>or(Collection<? extends Predicate<T>> that)Combine the passed predicates into a single OR node.booleansupportedForQueries()Whether this predicate can be used in search queries.
 
- 
- 
- 
Method Detail- 
getPredicateStringpublic String getPredicateString() 
 - 
isLeafpublic boolean isLeaf() 
 - 
anypublic static <T> Predicate<T> any() A predicate that matches any input, always, with no cost.
 - 
and@SafeVarargs public static <T> Predicate<T> and(Predicate<T>... that) Combine the passed predicates into a single AND node.
 - 
andpublic static <T> Predicate<T> and(Collection<? extends Predicate<T>> that) Combine the passed predicates into a single AND node.
 - 
or@SafeVarargs public static <T> Predicate<T> or(Predicate<T>... that) Combine the passed predicates into a single OR node.
 - 
orpublic static <T> Predicate<T> or(Collection<? extends Predicate<T>> that) Combine the passed predicates into a single OR node.
 - 
getChildCountpublic int getChildCount() Same asgetChildren().size()
 - 
getLeafCountpublic int getLeafCount() Get the number of leaf terms in this predicate.
 - 
getFlattenedPredicateListpublic List<Predicate<T>> getFlattenedPredicateList() Returns a list of this predicate and all its descendants.
 - 
copypublic abstract Predicate<T> copy(Collection<? extends Predicate<T>> children) Create a copy of this predicate, with new children.
 - 
isMatchablepublic boolean isMatchable() 
 - 
supportedForQueriespublic boolean supportedForQueries() Whether this predicate can be used in search queries.
 - 
estimateCostpublic int estimateCost() Returns a cost estimate to run this predicate, higher figures cost more.
 
- 
 
-