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