View Javadoc
1   package org.andromda.andromdapp;
2   
3   import java.util.ArrayList;
4   import java.util.LinkedHashMap;
5   import java.util.List;
6   import java.util.Map;
7   
8   /**
9    * Represents a <conditions/> element, which groups more than
10   * one condition together.
11   *
12   * @author Chad Brandon
13   */
14  public class Conditions
15  {
16      /**
17       * The "and" type.
18       */
19      static final String TYPE_AND = "and";
20  
21      /**
22       * The "or" type.
23       */
24      static final String TYPE_OR = "or";
25  
26      /**
27       * The type of this conditions instance.
28       */
29      private String type;
30  
31      /**
32       * Gets the type of this conditions instance.
33       *
34       * @return Returns the type.
35       */
36      public String getType()
37      {
38          return this.type;
39      }
40  
41      /**
42       * Sets the type of this conditions instance.
43       *
44       * @param type The type to set.
45       */
46      public void setType(final String type)
47      {
48          this.type = type;
49      }
50  
51      /**
52       * Stores the conditions.
53       */
54      private final List<Condition> conditions = new ArrayList<Condition>();
55  
56      /**
57       * Adds a condition instance to this conditions.
58       *
59       * @param condition the condition which must apply to this conditions instance.
60       */
61      public void addCondition(final Condition condition)
62      {
63          this.conditions.add(condition);
64      }
65  
66      /**
67       * Gets the condition instances defined in this conditions instance.
68       *
69       * @return the conditions that are defined within this prompt.
70       */
71      public List<Condition> getConditions()
72      {
73          return this.conditions;
74      }
75  
76      /**
77       * Stores the output paths.
78       */
79      private final Map<String, String[]> outputPaths = new LinkedHashMap<String, String[]>();
80  
81      /**
82       * Adds a path to the output paths.
83       *
84       * @param path the path to the resulting output
85       * @param patterns any patterns to which the conditions should apply
86       */
87      public void addOutputPath(
88          final String path,
89          final String patterns)
90      {
91          this.outputPaths.put(
92              path,
93              AndroMDAppUtils.stringToArray(patterns));
94      }
95  
96      /**
97       * Gets the current output paths for this condition.
98       *
99       * @return the map of output paths and its patterns (if it has any defined).
100      */
101     final Map<String, String[]> getOutputPaths()
102     {
103         return this.outputPaths;
104     }
105 }