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