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