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