001: package org.drools.ruleflow.core;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.util.Map;
020:
021: /**
022: * Represents a split node in a RuleFlow.
023: * A split is a special kind of node with one incoming connection and
024: * multiple outgoing connections. The type of split decides which of the
025: * outgoing connections will be triggered when the incoming connection
026: * has been triggered.
027: *
028: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
029: */
030: public interface Split extends Node {
031:
032: int TYPE_UNDEFINED = 0;
033: /**
034: * All outgoing connections of a split of this type are triggered
035: * when its incoming connection has been triggered. A split of this
036: * type should have no constraints linked to any of its outgoing
037: * connections.
038: */
039: int TYPE_AND = 1;
040: /**
041: * Exactly one outgoing connection of a split of this type is triggered
042: * when its incoming connection has been triggered. Which connection
043: * is based on the constraints associated with each of the connections:
044: * the connection with the highest priority whose constraint is satisfied
045: * is triggered.
046: */
047: int TYPE_XOR = 2;
048: /**
049: * One or multiple outgoing connections of a split of this type are
050: * triggered when its incoming connection has been triggered. Which
051: * connections is based on the constraints associated with each of the
052: * connections: all connections whose constraint is satisfied are
053: * triggered.
054: */
055: int TYPE_OR = 3;
056:
057: /**
058: * Sets the type of the split.
059: *
060: * @param type The type of the split
061: * @throws IllegalArgumentException if type is null
062: */
063: void setType(int type);
064:
065: /**
066: * Returns the type of the split.
067: *
068: * @return the type of the split.
069: */
070: int getType();
071:
072: /**
073: * Returns the corresponding constraint of the given outgoing connection
074: *
075: * @param connection the outgoing connection
076: * @return the corresponding constraint of the given outgoing connection
077: * @throws IllegalArgumentException if <code>connection</code> is
078: * not a valid outgoing connection for this split
079: * @throws UnsupportedOperationException if this method is called
080: * on a split with split type of something else than XOR or OR
081: */
082: Constraint getConstraint(Connection connection);
083:
084: /**
085: * Method for setting a constraint corresponding to the given
086: * outgoing connection
087: *
088: * @param connection the outgoing connection
089: * @param constraint the constraint
090: * @throws IllegalArgumentException if <code>connection</code> is
091: * not a valid outgoing connection for this split
092: * @throws UnsupportedOperationException if the split type is
093: * something else than XOR or OR
094: */
095: void setConstraint(Connection connection, Constraint constraint);
096:
097: /**
098: * Returns the constraints of the split.
099: *
100: * @return a map containing for each connection the constraint associated with
101: * that connection, or null if no constraint has been specified yet for that connection
102: * @throws UnsupportedOperationException if this method is called
103: * on a split with split type of something else than XOR or OR
104: */
105: Map getConstraints();
106:
107: /**
108: * Convenience method for returning the incoming connection of the split.
109: *
110: * @return the incoming connection ot the split.
111: */
112: Connection getFrom();
113:
114: }
|