001package org.andromda.andromdapp; 002 003import java.util.ArrayList; 004import java.util.LinkedHashMap; 005import java.util.List; 006import java.util.Map; 007 008/** 009 * Represents a <conditions/> element, which groups more than 010 * one condition together. 011 * 012 * @author Chad Brandon 013 */ 014public class Conditions 015{ 016 /** 017 * The "and" type. 018 */ 019 static final String TYPE_AND = "and"; 020 021 /** 022 * The "or" type. 023 */ 024 static final String TYPE_OR = "or"; 025 026 /** 027 * The type of this conditions instance. 028 */ 029 private String type; 030 031 /** 032 * Gets the type of this conditions instance. 033 * 034 * @return Returns the type. 035 */ 036 public String getType() 037 { 038 return this.type; 039 } 040 041 /** 042 * Sets the type of this conditions instance. 043 * 044 * @param type The type to set. 045 */ 046 public void setType(final String type) 047 { 048 this.type = type; 049 } 050 051 /** 052 * Stores the conditions. 053 */ 054 private final List<Condition> conditions = new ArrayList<Condition>(); 055 056 /** 057 * Adds a condition instance to this conditions. 058 * 059 * @param condition the condition which must apply to this conditions instance. 060 */ 061 public void addCondition(final Condition condition) 062 { 063 this.conditions.add(condition); 064 } 065 066 /** 067 * Gets the condition instances defined in this conditions instance. 068 * 069 * @return the conditions that are defined within this prompt. 070 */ 071 public List<Condition> getConditions() 072 { 073 return this.conditions; 074 } 075 076 /** 077 * Stores the output paths. 078 */ 079 private final Map<String, String[]> outputPaths = new LinkedHashMap<String, String[]>(); 080 081 /** 082 * Adds a path to the output paths. 083 * 084 * @param path the path to the resulting output 085 * @param patterns any patterns to which the conditions should apply 086 */ 087 public void addOutputPath( 088 final String path, 089 final String patterns) 090 { 091 this.outputPaths.put( 092 path, 093 AndroMDAppUtils.stringToArray(patterns)); 094 } 095 096 /** 097 * Gets the current output paths for this condition. 098 * 099 * @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}