001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.engine.node;
017
018import java.util.Collection;
019
020/**
021 * The criteria defining parameters to a search through a document's node graph.
022 *
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 */
025public class NodeGraphSearchCriteria {
026
027        // search directions
028        public static final int SEARCH_DIRECTION_FORWARD = 1;
029        public static final int SEARCH_DIRECTION_BACKWARD = 2;
030        public static final int SEARCH_DIRECTION_BOTH = 3;
031        
032        private int searchDirection = SEARCH_DIRECTION_FORWARD;
033        private Collection startingNodeInstances;
034        private NodeMatcher matcher;
035        
036        public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, NodeMatcher matcher) {
037                if (startingNodeInstances == null || startingNodeInstances.isEmpty()) {
038                        throw new IllegalArgumentException("Starting node instances were empty.  At least one starting node instance must be specified in order to perform a search.");
039                }
040                this.searchDirection = searchDirection;
041                this.startingNodeInstances = startingNodeInstances;
042                this.matcher = matcher;
043        }
044        
045        public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, String nodeName) {
046                this(searchDirection, startingNodeInstances, new NodeNameMatcher(nodeName));
047        }
048
049        public NodeMatcher getMatcher() {
050                return matcher;
051        }
052
053        public Collection getStartingNodeInstances() {
054                return startingNodeInstances;
055        }
056        
057        public int getSearchDirection() {
058                return searchDirection;
059        }
060        
061}