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.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 * A set of goals to execute.
25 */
26 @Experimental
27 @Generated @ThreadSafe @Immutable
28 public class Execution
29 implements Serializable
30 {
31 /**
32 * Configuration to pass to the goals.
33 */
34 final XmlNode configuration;
35 /**
36 * The goals to execute.
37 */
38 final List<String> goals;
39
40 /**
41 * Constructor for this class, to be called from its subclasses and {@link Builder}.
42 * @see Builder#build()
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 * Configuration to pass to the goals.
51 *
52 * @return a {@code XmlNode}
53 */
54 public XmlNode getConfiguration() {
55 return this.configuration;
56 }
57
58 /**
59 * The goals to execute.
60 *
61 * @return a {@code List<String>}
62 */
63 @Nonnull
64 public List<String> getGoals() {
65 return this.goals;
66 }
67
68 /**
69 * Creates a new builder with this object as the basis.
70 *
71 * @return a {@code Builder}
72 */
73 @Nonnull
74 public Builder with() {
75 return newBuilder(this);
76 }
77 /**
78 * Creates a new {@code Execution} instance using the specified configuration.
79 *
80 * @param configuration the new {@code XmlNode} to use
81 * @return a {@code Execution} with the specified configuration
82 */
83 @Nonnull
84 public Execution withConfiguration(XmlNode configuration) {
85 return newBuilder(this, true).configuration(configuration).build();
86 }
87 /**
88 * Creates a new {@code Execution} instance using the specified goals.
89 *
90 * @param goals the new {@code Collection<String>} to use
91 * @return a {@code Execution} with the specified goals
92 */
93 @Nonnull
94 public Execution withGoals(Collection<String> goals) {
95 return newBuilder(this, true).goals(goals).build();
96 }
97
98 /**
99 * Creates a new {@code Execution} instance.
100 * Equivalent to {@code newInstance(true)}.
101 * @see #newInstance(boolean)
102 *
103 * @return a new {@code Execution}
104 */
105 @Nonnull
106 public static Execution newInstance() {
107 return newInstance(true);
108 }
109
110 /**
111 * Creates a new {@code Execution} instance using default values or not.
112 * Equivalent to {@code newBuilder(withDefaults).build()}.
113 *
114 * @param withDefaults the boolean indicating whether default values should be used
115 * @return a new {@code Execution}
116 */
117 @Nonnull
118 public static Execution newInstance(boolean withDefaults) {
119 return newBuilder(withDefaults).build();
120 }
121
122 /**
123 * Creates a new {@code Execution} builder instance.
124 * Equivalent to {@code newBuilder(true)}.
125 * @see #newBuilder(boolean)
126 *
127 * @return a new {@code Builder}
128 */
129 @Nonnull
130 public static Builder newBuilder() {
131 return newBuilder(true);
132 }
133
134 /**
135 * Creates a new {@code Execution} builder instance using default values or not.
136 *
137 * @param withDefaults the boolean indicating whether default values should be used
138 * @return a new {@code Builder}
139 */
140 @Nonnull
141 public static Builder newBuilder(boolean withDefaults) {
142 return new Builder(withDefaults);
143 }
144
145 /**
146 * Creates a new {@code Execution} builder instance using the specified object as a basis.
147 * Equivalent to {@code newBuilder(from, false)}.
148 *
149 * @param from the {@code Execution} instance to use as a basis
150 * @return a new {@code Builder}
151 */
152 @Nonnull
153 public static Builder newBuilder(Execution from) {
154 return newBuilder(from, false);
155 }
156
157 /**
158 * Creates a new {@code Execution} builder instance using the specified object as a basis.
159 *
160 * @param from the {@code Execution} instance to use as a basis
161 * @param forceCopy the boolean indicating if a copy should be forced
162 * @return a new {@code Builder}
163 */
164 @Nonnull
165 public static Builder newBuilder(Execution from, boolean forceCopy) {
166 return new Builder(from, forceCopy);
167 }
168
169 /**
170 * Builder class used to create Execution instances.
171 * @see #with()
172 * @see #newBuilder()
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 // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
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 }