001package org.andromda.maven.plugin.andromdapp.utils; 002 003import java.util.ArrayList; 004import java.util.Collection; 005 006/** 007 * Stores projects ids. 008 * 009 * @author Chad Brandon 010 */ 011public class Projects 012{ 013 private Collection<String> projects = new ArrayList<String>(); 014 015 /** 016 * The shared instance of this class. 017 */ 018 private static Projects instance; 019 020 /** 021 * Retrieves the shared instance of this class. 022 * 023 * @return the shared instance. 024 */ 025 public static Projects instance() 026 { 027 if (instance == null) 028 { 029 instance = new Projects(); 030 } 031 return instance; 032 } 033 034 /** 035 * Adds the project id to the store. 036 * 037 * @param projectId the project id. 038 */ 039 public void add(final String projectId) 040 { 041 this.projects.add(projectId); 042 } 043 044 /** 045 * Indicates whether or not the project is present. 046 * 047 * @param projectId the identifier of the project. 048 * @return true/false 049 */ 050 public synchronized boolean isPresent(final String projectId) 051 { 052 return projects.contains(projectId); 053 } 054 055 /** 056 * Clears out any existing projects. 057 */ 058 public void clear() 059 { 060 this.projects.clear(); 061 Projects.instance = null; 062 } 063}