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