View Javadoc
1   package org.andromda.maven.plugin.andromdapp.utils;
2   
3   import java.util.ArrayList;
4   import java.util.Collection;
5   
6   /**
7    * Stores projects ids.
8    *
9    * @author Chad Brandon
10   */
11  public class Projects
12  {
13      private Collection<String> projects = new ArrayList<String>();
14  
15      /**
16       * The shared instance of this class.
17       */
18      private static Projects instance;
19  
20      /**
21       * Retrieves the shared instance of this class.
22       *
23       * @return the shared instance.
24       */
25      public static Projects instance()
26      {
27          if (instance == null)
28          {
29              instance = new Projects();
30          }
31          return instance;
32      }
33  
34      /**
35       * Adds the project id to the store.
36       *
37       * @param projectId the project id.
38       */
39      public void add(final String projectId)
40      {
41          this.projects.add(projectId);
42      }
43  
44      /**
45       * Indicates whether or not the project is present.
46       *
47       * @param projectId the identifier of the project.
48       * @return true/false
49       */
50      public synchronized boolean isPresent(final String projectId)
51      {
52          return projects.contains(projectId);
53      }
54  
55      /**
56       * Clears out any existing projects.
57       */
58      public void clear()
59      {
60          this.projects.clear();
61          Projects.instance = null;
62      }
63  }