1 package org.apache.maven.model.building;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.apache.maven.model.Model;
28 import org.apache.maven.model.Profile;
29
30
31
32
33
34
35 class DefaultModelBuildingResult
36 implements ModelBuildingResult
37 {
38
39 private Model effectiveModel;
40
41 private List<String> modelIds;
42
43 private Map<String, Model> rawModels;
44
45 private Map<String, List<Profile>> activePomProfiles;
46
47 private List<Profile> activeExternalProfiles;
48
49 private List<ModelProblem> problems;
50
51 public DefaultModelBuildingResult()
52 {
53 modelIds = new ArrayList<String>();
54 rawModels = new HashMap<String, Model>();
55 activePomProfiles = new HashMap<String, List<Profile>>();
56 activeExternalProfiles = new ArrayList<Profile>();
57 problems = new ArrayList<ModelProblem>();
58 }
59
60 @Override
61 public Model getEffectiveModel()
62 {
63 return effectiveModel;
64 }
65
66 public DefaultModelBuildingResult setEffectiveModel( Model model )
67 {
68 this.effectiveModel = model;
69
70 return this;
71 }
72
73 @Override
74 public List<String> getModelIds()
75 {
76 return modelIds;
77 }
78
79 public DefaultModelBuildingResult addModelId( String modelId )
80 {
81 if ( modelId == null )
82 {
83 throw new IllegalArgumentException( "no model identifier specified" );
84 }
85
86 modelIds.add( modelId );
87
88 return this;
89 }
90
91 @Override
92 public Model getRawModel()
93 {
94 return rawModels.get( modelIds.get( 0 ) );
95 }
96
97 @Override
98 public Model getRawModel( String modelId )
99 {
100 return rawModels.get( modelId );
101 }
102
103 public DefaultModelBuildingResult setRawModel( String modelId, Model rawModel )
104 {
105 if ( modelId == null )
106 {
107 throw new IllegalArgumentException( "no model identifier specified" );
108 }
109
110 rawModels.put( modelId, rawModel );
111
112 return this;
113 }
114
115 @Override
116 public List<Profile> getActivePomProfiles( String modelId )
117 {
118 return activePomProfiles.get( modelId );
119 }
120
121 public DefaultModelBuildingResult setActivePomProfiles( String modelId, List<Profile> activeProfiles )
122 {
123 if ( modelId == null )
124 {
125 throw new IllegalArgumentException( "no model identifier specified" );
126 }
127
128 if ( activeProfiles != null )
129 {
130 this.activePomProfiles.put( modelId, new ArrayList<Profile>( activeProfiles ) );
131 }
132 else
133 {
134 this.activePomProfiles.remove( modelId );
135 }
136
137 return this;
138 }
139
140 @Override
141 public List<Profile> getActiveExternalProfiles()
142 {
143 return activeExternalProfiles;
144 }
145
146 public DefaultModelBuildingResult setActiveExternalProfiles( List<Profile> activeProfiles )
147 {
148 if ( activeProfiles != null )
149 {
150 this.activeExternalProfiles = new ArrayList<Profile>( activeProfiles );
151 }
152 else
153 {
154 this.activeExternalProfiles.clear();
155 }
156
157 return this;
158 }
159
160 @Override
161 public List<ModelProblem> getProblems()
162 {
163 return problems;
164 }
165
166 public DefaultModelBuildingResult setProblems( List<ModelProblem> problems )
167 {
168 if ( problems != null )
169 {
170 this.problems = new ArrayList<ModelProblem>( problems );
171 }
172 else
173 {
174 this.problems.clear();
175 }
176
177 return this;
178 }
179
180 }