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