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