1 // =================== DO NOT EDIT THIS FILE ====================
2 // Generated by Modello Velocity from model.vm
3 // template, any modifications will be overwritten.
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.Objects;
15 import java.util.Optional;
16 import java.util.Set;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
19 import org.apache.maven.api.annotations.Experimental;
20 import org.apache.maven.api.annotations.Generated;
21 import org.apache.maven.api.annotations.Immutable;
22 import org.apache.maven.api.annotations.Nonnull;
23 import org.apache.maven.api.annotations.NotThreadSafe;
24 import org.apache.maven.api.annotations.ThreadSafe;
25 import org.apache.maven.api.xml.XmlNode;
26
27 /**
28 * A set of goals to execute.
29 */
30 @Experimental
31 @Generated @ThreadSafe @Immutable
32 public class Execution
33 implements Serializable
34 {
35 /**
36 * Configuration to pass to the goals.
37 */
38 final XmlNode configuration;
39 /**
40 * The goals to execute.
41 */
42 final List<String> goals;
43
44 /**
45 * Constructor for this class, to be called from its subclasses and {@link Builder}.
46 * @see Builder#build()
47 */
48 protected Execution(Builder builder) {
49 this.configuration = builder.configuration != null ? builder.configuration : (builder.base != null ? builder.base.configuration : null);
50 this.goals = ImmutableCollections.copy(builder.goals != null ? builder.goals : (builder.base != null ? builder.base.goals : null));
51 }
52
53 /**
54 * Configuration to pass to the goals.
55 *
56 * @return a {@code XmlNode}
57 */
58 public XmlNode getConfiguration() {
59 return this.configuration;
60 }
61
62 /**
63 * The goals to execute.
64 *
65 * @return a {@code List<String>}
66 */
67 @Nonnull
68 public List<String> getGoals() {
69 return this.goals;
70 }
71
72 /**
73 * Creates a new builder with this object as the basis.
74 *
75 * @return a {@code Builder}
76 */
77 @Nonnull
78 public Builder with() {
79 return newBuilder(this);
80 }
81 /**
82 * Creates a new {@code Execution} instance using the specified configuration.
83 *
84 * @param configuration the new {@code XmlNode} to use
85 * @return a {@code Execution} with the specified configuration
86 */
87 @Nonnull
88 public Execution withConfiguration(XmlNode configuration) {
89 return newBuilder(this, true).configuration(configuration).build();
90 }
91 /**
92 * Creates a new {@code Execution} instance using the specified goals.
93 *
94 * @param goals the new {@code Collection<String>} to use
95 * @return a {@code Execution} with the specified goals
96 */
97 @Nonnull
98 public Execution withGoals(Collection<String> goals) {
99 return newBuilder(this, true).goals(goals).build();
100 }
101
102 /**
103 * Creates a new {@code Execution} instance.
104 * Equivalent to {@code newInstance(true)}.
105 * @see #newInstance(boolean)
106 *
107 * @return a new {@code Execution}
108 */
109 @Nonnull
110 public static Execution newInstance() {
111 return newInstance(true);
112 }
113
114 /**
115 * Creates a new {@code Execution} instance using default values or not.
116 * Equivalent to {@code newBuilder(withDefaults).build()}.
117 *
118 * @param withDefaults the boolean indicating whether default values should be used
119 * @return a new {@code Execution}
120 */
121 @Nonnull
122 public static Execution newInstance(boolean withDefaults) {
123 return newBuilder(withDefaults).build();
124 }
125
126 /**
127 * Creates a new {@code Execution} builder instance.
128 * Equivalent to {@code newBuilder(true)}.
129 * @see #newBuilder(boolean)
130 *
131 * @return a new {@code Builder}
132 */
133 @Nonnull
134 public static Builder newBuilder() {
135 return newBuilder(true);
136 }
137
138 /**
139 * Creates a new {@code Execution} builder instance using default values or not.
140 *
141 * @param withDefaults the boolean indicating whether default values should be used
142 * @return a new {@code Builder}
143 */
144 @Nonnull
145 public static Builder newBuilder(boolean withDefaults) {
146 return new Builder(withDefaults);
147 }
148
149 /**
150 * Creates a new {@code Execution} builder instance using the specified object as a basis.
151 * Equivalent to {@code newBuilder(from, false)}.
152 *
153 * @param from the {@code Execution} instance to use as a basis
154 * @return a new {@code Builder}
155 */
156 @Nonnull
157 public static Builder newBuilder(Execution from) {
158 return newBuilder(from, false);
159 }
160
161 /**
162 * Creates a new {@code Execution} builder instance using the specified object as a basis.
163 *
164 * @param from the {@code Execution} instance to use as a basis
165 * @param forceCopy the boolean indicating if a copy should be forced
166 * @return a new {@code Builder}
167 */
168 @Nonnull
169 public static Builder newBuilder(Execution from, boolean forceCopy) {
170 return new Builder(from, forceCopy);
171 }
172
173 /**
174 * Builder class used to create Execution instances.
175 * @see #with()
176 * @see #newBuilder()
177 */
178 @NotThreadSafe
179 public static class Builder
180 {
181 Execution base;
182 XmlNode configuration;
183 Collection<String> goals;
184
185 protected Builder(boolean withDefaults) {
186 if (withDefaults) {
187 }
188 }
189
190 protected Builder(Execution base, boolean forceCopy) {
191 if (forceCopy) {
192 this.configuration = base.configuration;
193 this.goals = base.goals;
194 } else {
195 this.base = base;
196 }
197 }
198
199 @Nonnull
200 public Builder configuration(XmlNode configuration) {
201 this.configuration = configuration;
202 return this;
203 }
204
205 @Nonnull
206 public Builder goals(Collection<String> goals) {
207 this.goals = goals;
208 return this;
209 }
210
211
212 @Nonnull
213 public Execution build() {
214 // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
215 if (base != null
216 && (configuration == null || configuration == base.configuration)
217 && (goals == null || goals == base.goals)
218 ) {
219 return base;
220 }
221 return new Execution(this);
222 }
223
224 }
225
226 }