01 package dk.deepthought.sidious.planner;
02
03 import java.util.Stack;
04
05 import dk.deepthought.sidious.supportsystem.Step;
06 import dk.deepthought.sidious.supportsystem.SuperLinkID;
07
08 /**
09 * This class represent a plan in the system.
10 * <p>
11 * The plan is accessed as a last-in-first-out (LIFO) stack.
12 *
13 * @author Deepthought
14 *
15 */
16 public class Plan {
17
18 /**
19 * The stack of steps.
20 */
21 private final Stack<Step> steps = new Stack<Step>();
22
23 /**
24 * The id of the requester.
25 */
26 private SuperLinkID id;
27
28 /**
29 * Empty default constructor.
30 */
31 public Plan() {
32 }
33
34 /**
35 * Adds a <code>Step</code> to this <code>Plan</code>.
36 *
37 * @param step
38 * the <code>Step</code> to be added to this <code>Plan</code>
39 *
40 */
41 public void add(Step step) {
42 steps.push(step);
43 }
44
45 /**
46 * Gets the steps that make up this plan.
47 * @return the steps
48 */
49 public Stack<Step> getSteps() {
50 return steps;
51 }
52
53 /**
54 * Returns the size plan. Which means the number of steps this plan consists
55 * of.
56 *
57 * @return the size of the plan
58 */
59 public int size() {
60 return steps.size();
61 }
62
63 /**
64 * Sets the id of the requester.
65 *
66 * @param id
67 * the id to set
68 */
69 public void setId(SuperLinkID id) {
70 this.id = id;
71 }
72
73 /**
74 * Returns the id of the requester.
75 *
76 * @return the id
77 */
78 public SuperLinkID getId() {
79 return id;
80 }
81
82 /* (non-Javadoc)
83 * @see java.lang.Object#toString()
84 */
85 @Override
86 public String toString() {
87 return getClass().getSimpleName() + "[steps=" + steps + "]";
88 }
89
90 }
|