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