/** * Search for an outgoing edge by a predicate. * * @param predicate A predicate over labels. * @return An outgoing edge matching the predicate, or {@code null} if no such edge exists. If * multiple edges have labels matching the predicate, it is undefined which one will be * added. */ public DAGEdge<V, E> getOutgoingEdgeWithLabel(Predicate<? super E> predicate) { Predicate<DAGEdge<?, E>> edgePred = DAGEdge.labelMatches(predicate); return Iterables.find(outgoingEdges, edgePred, null); }
/** * Get the back edge for a particular node and desire, if one exists. * @return The back edge, or {@code null} if no edge exists. * @see #getBackEdges() */ public synchronized DAGNode<Component, Dependency> getBackEdge(DAGNode<Component, Dependency> parent, Desire desire) { Predicate<DAGEdge<?, Dependency>> pred = DAGEdge.labelMatches(Dependency.hasInitialDesire(desire)); return FluentIterable.from(backEdges.get(parent)) .filter(pred) .first() .transform(DAGEdge.<Component, Dependency>extractTail()) .orNull(); }