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