1 // =================== DO NOT EDIT THIS FILE ====================
2 // Generated by Modello Velocity from model.vm
3 // template, any modifications will be overwritten.
4 // ==============================================================
5 package org.apache.maven.api.settings;
6
7 import java.io.Serializable;
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11 import org.apache.maven.api.annotations.Experimental;
12 import org.apache.maven.api.annotations.Generated;
13 import org.apache.maven.api.annotations.Immutable;
14 import org.apache.maven.api.annotations.Nonnull;
15 import org.apache.maven.api.annotations.NotThreadSafe;
16 import org.apache.maven.api.annotations.ThreadSafe;
17
18 /**
19 * common base class that contains code to track the source for
20 * this instance (USER|GLOBAL)
21 */
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class TrackableBase
25 implements Serializable
26 {
27
28 /**
29 * Constructor for this class, package protected.
30 * @see Builder#build()
31 */
32 TrackableBase(
33 )
34 {
35 }
36
37 /**
38 * Creates a new builder with this object as the basis.
39 *
40 * @return a {@code Builder}
41 */
42 @Nonnull
43 public Builder with()
44 {
45 return newBuilder( this );
46 }
47
48 /**
49 * Creates a new {@code TrackableBase} instance.
50 * Equivalent to {@code newInstance( true )}.
51 * @see #newInstance(boolean)
52 *
53 * @return a new {@code TrackableBase}
54 */
55 @Nonnull
56 public static TrackableBase newInstance()
57 {
58 return newInstance( true );
59 }
60
61 /**
62 * Creates a new {@code TrackableBase} instance using default values or not.
63 * Equivalent to {@code newBuilder( withDefaults ).build()}.
64 *
65 * @param withDefaults the boolean indicating whether default values should be used
66 * @return a new {@code TrackableBase}
67 */
68 @Nonnull
69 public static TrackableBase newInstance( boolean withDefaults )
70 {
71 return newBuilder( withDefaults ).build();
72 }
73
74 /**
75 * Creates a new {@code TrackableBase} builder instance.
76 * Equivalent to {@code newBuilder( true )}.
77 * @see #newBuilder(boolean)
78 *
79 * @return a new {@code Builder}
80 */
81 @Nonnull
82 public static Builder newBuilder()
83 {
84 return newBuilder( true );
85 }
86
87 /**
88 * Creates a new {@code TrackableBase} builder instance using default values or not.
89 *
90 * @param withDefaults the boolean indicating whether default values should be used
91 * @return a new {@code Builder}
92 */
93 @Nonnull
94 public static Builder newBuilder( boolean withDefaults )
95 {
96 return new Builder( withDefaults );
97 }
98
99 /**
100 * Creates a new {@code TrackableBase} builder instance using the specified object as a basis.
101 * Equivalent to {@code newBuilder( from, false )}.
102 *
103 * @param from the {@code TrackableBase} instance to use as a basis
104 * @return a new {@code Builder}
105 */
106 @Nonnull
107 public static Builder newBuilder( TrackableBase from )
108 {
109 return newBuilder( from, false );
110 }
111
112 /**
113 * Creates a new {@code TrackableBase} builder instance using the specified object as a basis.
114 *
115 * @param from the {@code TrackableBase} instance to use as a basis
116 * @param forceCopy the boolean indicating if a copy should be forced
117 * @return a new {@code Builder}
118 */
119 @Nonnull
120 public static Builder newBuilder( TrackableBase from, boolean forceCopy )
121 {
122 return new Builder( from, forceCopy );
123 }
124
125 /**
126 * Builder class used to create TrackableBase instances.
127 * @see #with()
128 * @see #newBuilder()
129 */
130 @NotThreadSafe
131 public static class Builder
132 {
133 TrackableBase base;
134
135 Builder( boolean withDefaults )
136 {
137 if ( withDefaults )
138 {
139 }
140 }
141
142 Builder( TrackableBase base, boolean forceCopy )
143 {
144 if ( forceCopy )
145 {
146 }
147 else
148 {
149 this.base = base;
150 }
151 }
152
153
154 @Nonnull
155 public TrackableBase build()
156 {
157 if ( base != null
158 )
159 {
160 return base;
161 }
162 return new TrackableBase(
163 );
164 }
165 }
166
167
168
169 public static final String USER_LEVEL = "user-level";
170 public static final String GLOBAL_LEVEL = "global-level";
171
172 private String sourceLevel = USER_LEVEL;
173 private boolean sourceLevelSet = false;
174
175 public void setSourceLevel( String sourceLevel )
176 {
177 if ( sourceLevelSet )
178 {
179 throw new IllegalStateException( "Cannot reset sourceLevel attribute; it is already set to: " + sourceLevel );
180 }
181 else if ( !( USER_LEVEL.equals( sourceLevel ) || GLOBAL_LEVEL.equals( sourceLevel ) ) )
182 {
183 throw new IllegalArgumentException( "sourceLevel must be one of: {" + USER_LEVEL + "," + GLOBAL_LEVEL + "}" );
184 }
185 else
186 {
187 this.sourceLevel = sourceLevel;
188 this.sourceLevelSet = true;
189 }
190 }
191
192 public String getSourceLevel()
193 {
194 return sourceLevel;
195 }
196
197
198 }