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 this.id = id;
53 this.executions = ImmutableCollections.copy(executions);
54 this.configuration = configuration;
55 }
56
57
58
59
60
61
62 public String getId() {
63 return this.id;
64 }
65
66
67
68
69
70
71 @Nonnull
72 public List<Execution> getExecutions() {
73 return this.executions;
74 }
75
76
77
78
79
80
81 public XmlNode getConfiguration() {
82 return this.configuration;
83 }
84
85
86
87
88
89
90 @Nonnull
91 public Builder with() {
92 return newBuilder(this);
93 }
94
95
96
97
98
99
100 @Nonnull
101 public Phase withId(String id) {
102 return newBuilder(this, true).id(id).build();
103 }
104
105
106
107
108
109
110 @Nonnull
111 public Phase withExecutions(Collection<Execution> executions) {
112 return newBuilder(this, true).executions(executions).build();
113 }
114
115
116
117
118
119
120 @Nonnull
121 public Phase withConfiguration(XmlNode configuration) {
122 return newBuilder(this, true).configuration(configuration).build();
123 }
124
125
126
127
128
129
130
131
132 @Nonnull
133 public static Phase newInstance() {
134 return newInstance(true);
135 }
136
137
138
139
140
141
142
143
144 @Nonnull
145 public static Phase newInstance(boolean withDefaults) {
146 return newBuilder(withDefaults).build();
147 }
148
149
150
151
152
153
154
155
156 @Nonnull
157 public static Builder newBuilder() {
158 return newBuilder(true);
159 }
160
161
162
163
164
165
166
167 @Nonnull
168 public static Builder newBuilder(boolean withDefaults) {
169 return new Builder(withDefaults);
170 }
171
172
173
174
175
176
177
178
179 @Nonnull
180 public static Builder newBuilder(Phase from) {
181 return newBuilder(from, false);
182 }
183
184
185
186
187
188
189
190
191 @Nonnull
192 public static Builder newBuilder(Phase from, boolean forceCopy) {
193 return new Builder(from, forceCopy);
194 }
195
196
197
198
199
200
201 @NotThreadSafe
202 public static class Builder
203 {
204 Phase base;
205 String id;
206 Collection<Execution> executions;
207 XmlNode configuration;
208
209 Builder(boolean withDefaults) {
210 if (withDefaults) {
211 }
212 }
213
214 Builder(Phase base, boolean forceCopy) {
215 if (forceCopy) {
216 this.id = base.id;
217 this.executions = base.executions;
218 this.configuration = base.configuration;
219 } else {
220 this.base = base;
221 }
222 }
223
224 @Nonnull
225 public Builder id(String id) {
226 this.id = id;
227 return this;
228 }
229
230 @Nonnull
231 public Builder executions(Collection<Execution> executions) {
232 this.executions = executions;
233 return this;
234 }
235
236 @Nonnull
237 public Builder configuration(XmlNode configuration) {
238 this.configuration = configuration;
239 return this;
240 }
241
242
243 @Nonnull
244 public Phase build() {
245 if (base != null
246 && (id == null || id == base.id)
247 && (executions == null || executions == base.executions)
248 && (configuration == null || configuration == base.configuration)
249 ) {
250 return base;
251 }
252 return new Phase(
253 id != null ? id : (base != null ? base.id : null),
254 executions != null ? executions : (base != null ? base.executions : null),
255 configuration != null ? configuration : (base != null ? base.configuration : null)
256 );
257 }
258 }
259
260 }