List of usage examples for com.google.common.base Predicate equals
@Override
boolean equals(@Nullable Object object);
From source file:edu.uci.ics.jung.visualization.picking.ShapePickSupport.java
/** * Quick test to allow optimization of <code>getFilteredEdges()</code>. * @return <code>true</code> if there is an active edge filtering * mechanism for this visualization, <code>false</code> otherwise *///from w ww . ja v a 2 s . c o m protected boolean edgesAreFiltered() { Predicate<Context<Graph<V, E>, E>> edgeIncludePredicate = vv.getRenderContext().getEdgeIncludePredicate(); return edgeIncludePredicate != null && edgeIncludePredicate.equals(Predicates.alwaysTrue()) == false; }
From source file:edu.uci.ics.jung.visualization.picking.ShapePickSupport.java
/** * Quick test to allow optimization of <code>getFilteredVertices()</code>. * @return <code>true</code> if there is an active vertex filtering * mechanism for this visualization, <code>false</code> otherwise *//*from w ww . ja va 2 s.c o m*/ protected boolean verticesAreFiltered() { Predicate<Context<Graph<V, E>, V>> vertexIncludePredicate = vv.getRenderContext() .getVertexIncludePredicate(); return vertexIncludePredicate != null && vertexIncludePredicate.equals(Predicates.alwaysTrue()) == false; }
From source file:org.kitesdk.data.spi.Constraints.java
/** * If this returns true, the entities selected by this set of constraints * align to partition boundaries./*from w w w .j a v a2 s . co m*/ * * For example, for a partition strategy [hash(num), identity(num)], * any constraint on the "num" field will be correctly enforced by the * partition predicate for this constraint set. However, a "color" field * wouldn't be satisfied by considering partition values alone and would * require further checks. * * An alternate explanation: This returns whether the key {@link Predicate} * from {@link #toKeyPredicate()} is equivalent to this set of constraints * under the given {@link PartitionStrategy}. The key predicate must accept a * key if that key's partition might include entities matched by this * constraint set. If this method returns true, then all entities in the * partitions it matches are guaranteed to match this constraint set. So, the * partitions are equivalent to the constraints. * * @return true if this constraint set is satisfied by partitioning * @throws NullPointerException if no partition strategy is defined */ @SuppressWarnings("unchecked") public boolean alignedWithBoundaries() { Preconditions.checkNotNull(strategy, "Cannot produce key ranges without a partition strategy"); Multimap<String, FieldPartitioner> partitioners = HashMultimap.create(); for (FieldPartitioner fp : strategy.getFieldPartitioners()) { partitioners.put(fp.getSourceName(), fp); } // The key predicate is equivalent to a constraint set when the permissive // projection for each predicate can be used in its place. This happens if // fp.project(predicate) == fp.projectStrict(predicate): // // let D = some value domain // let pred : D -> {0, 1} // let D_{pred} = {x \in D | pred(x) == 1} (a subset of D selected by pred) // // let fp : D -> S (also a value domain) // let fp.strict(pred) = pred_{fp.strict} : S -> {0, 1} (project strict) // s.t. pred_{fp.strict}(fp(x)) == 1 => pred(x) == 1 // let fp.project(pred) = pred_{fp.project} : S -> {0, 1} (project) // s.t. pred(x) == 1 => pred_{fp.project}(fp(x)) == 1 // // lemma. {x \in D | pred_{fp.strict}(fp(x))} is a subset of D_{pred} // pred_{fp.strict}(fp(x)) == 1 => pred(x) == 1 => x \in D_{pred} // // theorem. (pred_{fp.project}(s) => pred_{fp.strict}(s)) => // D_{pred} == {x \in D | pred_{fp.strict}(fp(x))} // // => let x \in D_{pred}. then pred_{fp.project}(fp(x)) == 1 by def // then pred_{fp.strict(fp(x)) == 1 by premise // therefore {x \in D | pred_{fp.strict}(fp(x))} \subsetOf D_{pred} // <= by previous lemma // // Note: if projectStrict is too conservative or project is too permissive, // then this logic cannot determine that that the original predicate is // satisfied for (Map.Entry<String, Predicate> entry : constraints.entrySet()) { Collection<FieldPartitioner> fps = partitioners.get(entry.getKey()); if (fps.isEmpty()) { LOG.debug("No field partitioners for key {}", entry.getKey()); return false; } Predicate predicate = entry.getValue(); if (!(predicate instanceof Predicates.Exists)) { boolean satisfied = false; for (FieldPartitioner fp : fps) { if (fp instanceof CalendarFieldPartitioner) { TimeDomain domain = TimeDomain.get(strategy, entry.getKey()); Predicate strict = domain.projectStrict(predicate); Predicate permissive = domain.project(predicate); LOG.debug("Time predicate strict: {}", strict); LOG.debug("Time predicate permissive: {}", permissive); satisfied = strict != null && strict.equals(permissive); break; } else { Predicate strict = fp.projectStrict(predicate); Predicate permissive = fp.project(predicate); if (strict != null && strict.equals(permissive)) { satisfied = true; break; } } } // this predicate cannot be satisfied by the partition information if (!satisfied) { LOG.debug("Predicate not satisfied: {}", predicate); return false; } } } return true; }