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