1
2
3
4 package org.apache.maven.settings;
5
6 import java.io.Serializable;
7 import java.util.AbstractList;
8 import java.util.ArrayList;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.List;
12 import java.util.Map;
13 import java.util.stream.Collectors;
14 import java.util.stream.Stream;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Nonnull;
17
18 @Generated
19 public class Settings
20 extends TrackableBase
21 implements Serializable, Cloneable
22 {
23
24
25 public Settings()
26 {
27 this( org.apache.maven.api.settings.Settings.newInstance() );
28 }
29
30 public Settings( org.apache.maven.api.settings.Settings delegate )
31 {
32 super( delegate );
33 }
34
35 public Settings clone()
36 {
37 return new Settings( getDelegate() );
38 }
39
40 @Override
41 public org.apache.maven.api.settings.Settings getDelegate()
42 {
43 return ( org.apache.maven.api.settings.Settings ) delegate;
44 }
45
46 public String getModelEncoding()
47 {
48 return getDelegate().getModelEncoding();
49 }
50
51 public String getLocalRepository()
52 {
53 return getDelegate().getLocalRepository();
54 }
55
56 public void setLocalRepository( String localRepository )
57 {
58 delegate = getDelegate().withLocalRepository( localRepository );
59 }
60
61 public boolean isInteractiveMode()
62 {
63 return getDelegate().isInteractiveMode();
64 }
65
66 public void setInteractiveMode( boolean interactiveMode )
67 {
68 delegate = getDelegate().withInteractiveMode( interactiveMode );
69 }
70
71 public boolean isUsePluginRegistry()
72 {
73 return getDelegate().isUsePluginRegistry();
74 }
75
76 public void setUsePluginRegistry( boolean usePluginRegistry )
77 {
78 delegate = getDelegate().withUsePluginRegistry( usePluginRegistry );
79 }
80
81 public boolean isOffline()
82 {
83 return getDelegate().isOffline();
84 }
85
86 public void setOffline( boolean offline )
87 {
88 delegate = getDelegate().withOffline( offline );
89 }
90
91 @Nonnull
92 public List<Proxy> getProxies()
93 {
94 return new WrapperList<Proxy, org.apache.maven.api.settings.Proxy>(
95 getDelegate()::getProxies, l -> delegate = getDelegate().withProxies( l ),
96 Proxy::new, Proxy::getDelegate );
97 }
98
99 public void setProxies( List<Proxy> proxies )
100 {
101 delegate = getDelegate().withProxies(
102 proxies.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) );
103 }
104
105 public void addProxy( Proxy proxy )
106 {
107 delegate = getDelegate().withProxies(
108 Stream.concat( getDelegate().getProxies().stream(), Stream.of( proxy.getDelegate() ) )
109 .collect( Collectors.toList() ) );
110 }
111
112 @Nonnull
113 public List<Server> getServers()
114 {
115 return new WrapperList<Server, org.apache.maven.api.settings.Server>(
116 getDelegate()::getServers, l -> delegate = getDelegate().withServers( l ),
117 Server::new, Server::getDelegate );
118 }
119
120 public void setServers( List<Server> servers )
121 {
122 delegate = getDelegate().withServers(
123 servers.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) );
124 }
125
126 public void addServer( Server server )
127 {
128 delegate = getDelegate().withServers(
129 Stream.concat( getDelegate().getServers().stream(), Stream.of( server.getDelegate() ) )
130 .collect( Collectors.toList() ) );
131 }
132
133 @Nonnull
134 public List<Mirror> getMirrors()
135 {
136 return new WrapperList<Mirror, org.apache.maven.api.settings.Mirror>(
137 getDelegate()::getMirrors, l -> delegate = getDelegate().withMirrors( l ),
138 Mirror::new, Mirror::getDelegate );
139 }
140
141 public void setMirrors( List<Mirror> mirrors )
142 {
143 delegate = getDelegate().withMirrors(
144 mirrors.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) );
145 }
146
147 public void addMirror( Mirror mirror )
148 {
149 delegate = getDelegate().withMirrors(
150 Stream.concat( getDelegate().getMirrors().stream(), Stream.of( mirror.getDelegate() ) )
151 .collect( Collectors.toList() ) );
152 }
153
154 @Nonnull
155 public List<Profile> getProfiles()
156 {
157 return new WrapperList<Profile, org.apache.maven.api.settings.Profile>(
158 getDelegate()::getProfiles, l -> delegate = getDelegate().withProfiles( l ),
159 Profile::new, Profile::getDelegate );
160 }
161
162 public void setProfiles( List<Profile> profiles )
163 {
164 delegate = getDelegate().withProfiles(
165 profiles.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) );
166 }
167
168 public void addProfile( Profile profile )
169 {
170 delegate = getDelegate().withProfiles(
171 Stream.concat( getDelegate().getProfiles().stream(), Stream.of( profile.getDelegate() ) )
172 .collect( Collectors.toList() ) );
173 }
174
175 @Nonnull
176 public List<String> getActiveProfiles()
177 {
178 return new WrapperList<String, String>( getDelegate()::getActiveProfiles, this::setActiveProfiles, s -> s, s -> s );
179 }
180
181 public void setActiveProfiles( List<String> activeProfiles )
182 {
183 delegate = getDelegate().withActiveProfiles( activeProfiles );
184 }
185
186 public void addActiveProfile( String activeProfile )
187 {
188 delegate = getDelegate().withActiveProfiles(
189 Stream.concat( getDelegate().getActiveProfiles().stream(), Stream.of( activeProfile ) )
190 .collect( Collectors.toList() ) );
191 }
192
193 @Nonnull
194 public List<String> getPluginGroups()
195 {
196 return new WrapperList<String, String>( getDelegate()::getPluginGroups, this::setPluginGroups, s -> s, s -> s );
197 }
198
199 public void setPluginGroups( List<String> pluginGroups )
200 {
201 delegate = getDelegate().withPluginGroups( pluginGroups );
202 }
203
204 public void addPluginGroup( String pluginGroup )
205 {
206 delegate = getDelegate().withPluginGroups(
207 Stream.concat( getDelegate().getPluginGroups().stream(), Stream.of( pluginGroup ) )
208 .collect( Collectors.toList() ) );
209 }
210
211 public static List<org.apache.maven.api.settings.Settings> settingsToApiV4( List<Settings> list )
212 {
213 return list != null ? new WrapperList<>( list, Settings::getDelegate, Settings::new ) : null;
214 }
215
216 public static List<Settings> settingsToApiV3( List<org.apache.maven.api.settings.Settings> list )
217 {
218 return list != null ? new WrapperList<>( list, Settings::new, Settings::getDelegate ) : null;
219 }
220
221
222
223 public Boolean getInteractiveMode()
224 {
225 return Boolean.valueOf( isInteractiveMode() );
226 }
227
228 private Proxy activeProxy;
229
230
231
232
233 public void flushActiveProxy()
234 {
235 this.activeProxy = null;
236 }
237
238
239
240
241 public synchronized Proxy getActiveProxy()
242 {
243 if ( activeProxy == null )
244 {
245 java.util.List<Proxy> proxies = getProxies();
246 if ( proxies != null && !proxies.isEmpty() )
247 {
248 for ( Proxy proxy : proxies )
249 {
250 if ( proxy.isActive() )
251 {
252 activeProxy = proxy;
253 break;
254 }
255 }
256 }
257 }
258
259 return activeProxy;
260 }
261
262 public Server getServer( String serverId )
263 {
264 Server match = null;
265
266 java.util.List<Server> servers = getServers();
267 if ( servers != null && serverId != null )
268 {
269 for ( Server server : servers )
270 {
271 if ( serverId.equals( server.getId() ) )
272 {
273 match = server;
274 break;
275 }
276 }
277 }
278
279 return match;
280 }
281
282 @Deprecated
283 public Mirror getMirrorOf( String repositoryId )
284 {
285 Mirror match = null;
286
287 java.util.List<Mirror> mirrors = getMirrors();
288 if ( mirrors != null && repositoryId != null )
289 {
290 for ( Mirror mirror : mirrors )
291 {
292 if ( repositoryId.equals( mirror.getMirrorOf() ) )
293 {
294 match = mirror;
295 break;
296 }
297 }
298 }
299
300 return match;
301 }
302
303 private java.util.Map<String, Profile> profileMap;
304
305
306
307
308 public void flushProfileMap()
309 {
310 this.profileMap = null;
311 }
312
313
314
315
316
317 public java.util.Map<String, Profile> getProfilesAsMap()
318 {
319 if ( profileMap == null )
320 {
321 profileMap = new java.util.LinkedHashMap<String, Profile>();
322
323 if ( getProfiles() != null )
324 {
325 for ( Profile profile : getProfiles() )
326 {
327 profileMap.put( profile.getId(), profile );
328 }
329 }
330 }
331
332 return profileMap;
333 }
334
335
336 }