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