Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/transition/TransitionEngine.java @ 244:3d14fe6e05f7
Improved the describe() of a State - a reference to an artifact has been added.
artifacts/trunk@1683 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 14 Apr 2011 08:26:25 +0000 |
parents | 973f244ed568 |
children | 8c2b6cdf22ad |
rev | line source |
---|---|
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase.transition; |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
3 import java.util.ArrayList; |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.HashMap; |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import java.util.List; |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import java.util.Map; |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
10 import de.intevation.artifactdatabase.state.State; |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
11 import de.intevation.artifactdatabase.state.StateEngine; |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
12 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
13 |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 /** |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * The TransitionEngine stores all transitions for each Artifact and should be |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 * used to determine, if an Artifact is able to advance from one to another |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 * state. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 * |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 */ |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public class TransitionEngine { |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** The logger used in this class. */ |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 private static Logger logger = Logger.getLogger(TransitionEngine.class); |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 /** |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * A map that contains the transitions of the artifacts. The key is the name |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 * of the artifact, its value is a list of all transitions of this artifact. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 */ |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 protected Map<String, List> transitions; |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 /** |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * The default constructor. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 */ |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 public TransitionEngine() { |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 transitions = new HashMap<String, List>(); |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 } |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 /** |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 * Add new transitions for a specific artifact. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 * |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 * @param stateId the name of the Artifact. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 * @param transitions the list of transition of the artifact. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 * |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 * @return true, if the transitions were added, otherwise false. |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 */ |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
49 public boolean addTransition(String stateId, Transition transition) { |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
50 List tmp = transitions.get(stateId); |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
52 if (tmp == null) { |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
53 tmp = new ArrayList<Transition>(); |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 } |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
56 tmp.add(transition); |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
57 |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 logger.debug("Add new transitions for state '" + stateId + "'"); |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
59 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
60 return transitions.put(stateId, tmp) != null; |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
61 } |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
62 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
63 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
64 /** |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
65 * This method returns all existing transitions of a state. |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
66 * |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
67 * @param state The state |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
68 * |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
69 * @return the existing transition of <i>state</i>. |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
70 */ |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
71 public List<Transition> getTransitions(State state) { |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
72 return transitions.get(state.getID()); |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
73 } |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
74 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
75 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
76 /** |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
77 * This method returns the reachable states of <i>state</i>. |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
78 * |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
79 * @param state The current state. |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
80 * @param engine The state engine. |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
81 * |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
82 * @return a list of reachable states. |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
83 */ |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
84 public List<State> getReachableStates(State state, StateEngine engine) { |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
85 List<Transition> transitions = getTransitions(state); |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
86 List<State> reachable = new ArrayList<State>(); |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
87 |
201
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
88 if (transitions == null) { |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
89 return reachable; |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
90 } |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
91 |
108
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
92 for (Transition t: transitions) { |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
93 if (t.isValid(state)) { |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
94 reachable.add(engine.getState(t.getTo())); |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
95 } |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
96 } |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
97 |
9ece61d918b1
Improved the StateEngine and the TransitionEngine to retrieve the reachable states of a current state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
104
diff
changeset
|
98 return reachable; |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 } |
201
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
100 |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
101 |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
102 /** |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
103 * Determines if a state with a given identifier is reachable from a current |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
104 * state. |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
105 * |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
106 * @param targetId The identifier of the target state. |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
107 * @param state The start state. |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
108 * @param stateEngine The StateEngine. |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
109 * |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
110 * @return true, if the target state is reachable, otherwise false. |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
111 */ |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
112 public boolean isStateReachable( |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
113 String targetId, |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
114 State state, |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
115 StateEngine stateEngine) |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
116 { |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
117 List<State> reachable = getReachableStates(state, stateEngine); |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
118 |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
119 if (reachable == null || reachable.size() == 0) { |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
120 return false; |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
121 } |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
122 |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
123 for (State s: reachable) { |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
124 if (targetId.equals(s.getID())) { |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
125 return true; |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
126 } |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
127 } |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
128 |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
129 return false; |
973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
108
diff
changeset
|
130 } |
104
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 } |
26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |