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