1
2
3
4
5 package org.apache.maven.plugin.lifecycle;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.maven.api.annotations.Experimental;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Immutable;
17 import org.apache.maven.api.annotations.Nonnull;
18 import org.apache.maven.api.annotations.NotThreadSafe;
19 import org.apache.maven.api.annotations.ThreadSafe;
20 import org.apache.maven.api.xml.XmlNode;
21
22
23
24
25 @Experimental
26 @Generated @ThreadSafe @Immutable
27 public class Phase
28 implements Serializable
29 {
30
31
32
33 final String id;
34
35
36
37 final List<Execution> executions;
38
39
40
41 final XmlNode configuration;
42
43
44
45
46
47 Phase(
48 String id,
49 Collection<Execution> executions,
50 XmlNode configuration
51 )
52 {
53 this.id = id;
54 this.executions = ImmutableCollections.copy( executions );
55 this.configuration = configuration;
56 }
57
58
59
60
61
62
63 public String getId()
64 {
65 return this.id;
66 }
67
68
69
70
71
72
73 @Nonnull
74 public List<Execution> getExecutions()
75 {
76 return this.executions;
77 }
78
79
80
81
82
83
84 public XmlNode getConfiguration()
85 {
86 return this.configuration;
87 }
88
89
90
91
92
93
94 @Nonnull
95 public Builder with()
96 {
97 return newBuilder( this );
98 }
99
100
101
102
103
104
105 @Nonnull
106 public Phase withId( String id )
107 {
108 return with().id( id ).build();
109 }
110
111
112
113
114
115
116 @Nonnull
117 public Phase withExecutions( Collection<Execution> executions )
118 {
119 return with().executions( executions ).build();
120 }
121
122
123
124
125
126
127 @Nonnull
128 public Phase withConfiguration( XmlNode configuration )
129 {
130 return with().configuration( configuration ).build();
131 }
132
133
134
135
136
137
138
139
140 @Nonnull
141 public static Phase newInstance()
142 {
143 return newInstance( true );
144 }
145
146
147
148
149
150
151
152
153 @Nonnull
154 public static Phase newInstance( boolean withDefaults )
155 {
156 return newBuilder( withDefaults ).build();
157 }
158
159
160
161
162
163
164
165
166 @Nonnull
167 public static Builder newBuilder()
168 {
169 return newBuilder( true );
170 }
171
172
173
174
175
176
177
178 @Nonnull
179 public static Builder newBuilder( boolean withDefaults )
180 {
181 return new Builder( withDefaults );
182 }
183
184
185
186
187
188
189
190
191 @Nonnull
192 public static Builder newBuilder( Phase from )
193 {
194 return newBuilder( from, false );
195 }
196
197
198
199
200
201
202
203
204 @Nonnull
205 public static Builder newBuilder( Phase from, boolean forceCopy )
206 {
207 return new Builder( from, forceCopy );
208 }
209
210
211
212
213
214
215 @NotThreadSafe
216 public static class Builder
217 {
218 Phase base;
219 String id;
220 Collection<Execution> executions;
221 XmlNode configuration;
222
223 Builder( boolean withDefaults )
224 {
225 if ( withDefaults )
226 {
227 }
228 }
229
230 Builder( Phase base, boolean forceCopy )
231 {
232 if ( forceCopy )
233 {
234 this.id = base.id;
235 this.executions = base.executions;
236 this.configuration = base.configuration;
237 }
238 else
239 {
240 this.base = base;
241 }
242 }
243
244 @Nonnull
245 public Builder id( String id )
246 {
247 this.id = id;
248 return this;
249 }
250
251 @Nonnull
252 public Builder executions( Collection<Execution> executions )
253 {
254 this.executions = executions;
255 return this;
256 }
257
258 @Nonnull
259 public Builder configuration( XmlNode configuration )
260 {
261 this.configuration = configuration;
262 return this;
263 }
264
265
266 @Nonnull
267 public Phase build()
268 {
269 if ( base != null
270 && ( id == null || id == base.id )
271 && ( executions == null || executions == base.executions )
272 && ( configuration == null || configuration == base.configuration )
273 )
274 {
275 return base;
276 }
277 return new Phase(
278 id != null ? id : ( base != null ? base.id : null ),
279 executions != null ? executions : ( base != null ? base.executions : null ),
280 configuration != null ? configuration : ( base != null ? base.configuration : null )
281 );
282 }
283 }
284
285 }