if (detectorSet.contains(constraint.getEarlierDetector()) || detectorSet.contains(constraint.getLaterDetector())) {   if (!(detectorSet.contains(constraint.getEarlierDetector()) && detectorSet.contains(constraint.getLaterDetector()))) { throw new OrderingConstraintException("Intra-pass constraint " + constraint.getEarlierDetector() + " earlier than " + constraint.getLaterDetector() + " involves detectors in " + "different passes"); }    if (firstDetector != null) { if (firstDetector.getFullName().equals(constraint.getEarlierDetector()) || firstDetector.getFullName().equals(constraint.getLaterDetector())) { throw new OrderingConstraintException("Detector specified as FirstInPass (" + firstDetector.getShortName() +") also appears in an ordering constraint"); } }
if (selectDetectors(constraint.getEarlier(), detectorSet).size() > 0 || selectDetectors(constraint.getLater(), detectorSet).size() > 0) {
	private void sortPass(			List<DetectorOrderingConstraint> constraintList,			Map<String, DetectorFactory> factoryMap,			AnalysisPass pass)		throws OrderingConstraintException {		// Preserve original order of detectors in pass		List<DetectorFactory> origDetectorList = new LinkedList<DetectorFactory>();		origDetectorList.addAll(pass.getDetectorFactoryList());		// Build set of all detectors in pass.		// Also, check to see if any detectors want to be		// first in the pass.		Set<String> detectorSet = new HashSet<String>();		DetectorFactory firstDetector = null;		for (Iterator<DetectorFactory> i = pass.detectorFactoryIterator();			i.hasNext(); ) {			DetectorFactory factory = i.next();			if (factory.isFirstInPass()) {				if (firstDetector != null) {					throw new OrderingConstraintException("Two detectors specified as first in analysis pass: " +						firstDetector.getFullName() + " and " + factory.getFullName());				} else					firstDetector = factory;			}			detectorSet.add(factory.getFullName());		}		// Build list of ordering constraints in this pass only		List<DetectorOrderingConstraint> passConstraintList =			new LinkedList<DetectorOrderingConstraint>();		for (Iterator<DetectorOrderingConstraint> i = constraintList.iterator(); i.hasNext(); ) {			DetectorOrderingConstraint constraint = i.next();			if (detectorSet.contains(constraint.getEarlierDetector()) ||				detectorSet.contains(constraint.getLaterDetector())) {				// Make sure that both detectors are in this pass				if (!(detectorSet.contains(constraint.getEarlierDetector()) &&						detectorSet.contains(constraint.getLaterDetector()))) {					throw new OrderingConstraintException("Intra-pass constraint " +						constraint.getEarlierDetector() + " earlier than " +						constraint.getLaterDetector() + " involves detectors in " +						"different passes");				}				// Make sure this constraint doesn't conflict with				// a FirstInPass directive (if any).				if (firstDetector != null) {					if (firstDetector.getFullName().equals(constraint.getEarlierDetector()) ||						firstDetector.getFullName().equals(constraint.getLaterDetector())) {						throw new OrderingConstraintException("Detector specified as FirstInPass (" +							firstDetector.getShortName() +") also appears in an ordering constraint");					}				}				passConstraintList.add(constraint);			}		}		// Build intra-pass constraint graph		Map<String, DetectorNode> nodeMap = new HashMap<String, DetectorNode>();		ConstraintGraph constraintGraph = buildConstraintGraph(			nodeMap, factoryMap, passConstraintList);		if (DEBUG) {			System.out.println("Pass constraint graph:");			dumpGraph(constraintGraph);		}		// Perform DFS, check for cycles		DepthFirstSearch<ConstraintGraph, ConstraintEdge, DetectorNode> dfs =			new DepthFirstSearch<ConstraintGraph, ConstraintEdge, DetectorNode>(constraintGraph);		dfs.search();		if (dfs.containsCycle())			throw new OrderingConstraintException("Cycle in intra-pass ordering constraints!");		// Do a topological sort to put the detectors in the pass		// in the right order.		pass.clear();		for (Iterator<DetectorNode> i = dfs.topologicalSortIterator(); i.hasNext(); ) {			DetectorNode node = i.next();			pass.addDetectorFactory(node.getFactory());		}		// Add back detectors that aren't involved in any intra-pass		// ordering constraints.		for (Iterator<DetectorFactory> i = origDetectorList.iterator(); i.hasNext(); ) {			DetectorFactory factory = i.next();			if (nodeMap.get(factory.getFullName()) == null) {				if (factory.isFirstInPass())					pass.prependDetectorFactory(factory);				else					pass.addDetectorFactory(factory);			}		}	}