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