View Javadoc
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.toolchain;
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       * Creates a new builder with this object as the basis.
38       *
39       * @return a {@code Builder}
40       */
41      @Nonnull
42      public Builder with() {
43          return newBuilder(this);
44      }
45  
46      /**
47       * Creates a new {@code TrackableBase} instance.
48       * Equivalent to {@code newInstance(true)}.
49       * @see #newInstance(boolean)
50       *
51       * @return a new {@code TrackableBase}
52       */
53      @Nonnull
54      public static TrackableBase newInstance() {
55          return newInstance(true);
56      }
57  
58      /**
59       * Creates a new {@code TrackableBase} instance using default values or not.
60       * Equivalent to {@code newBuilder(withDefaults).build()}.
61       *
62       * @param withDefaults the boolean indicating whether default values should be used
63       * @return a new {@code TrackableBase}
64       */
65      @Nonnull
66      public static TrackableBase newInstance(boolean withDefaults) {
67          return newBuilder(withDefaults).build();
68      }
69  
70      /**
71       * Creates a new {@code TrackableBase} builder instance.
72       * Equivalent to {@code newBuilder(true)}.
73       * @see #newBuilder(boolean)
74       *
75       * @return a new {@code Builder}
76       */
77      @Nonnull
78      public static Builder newBuilder() {
79          return newBuilder(true);
80      }
81  
82      /**
83       * Creates a new {@code TrackableBase} builder instance using default values or not.
84       *
85       * @param withDefaults the boolean indicating whether default values should be used
86       * @return a new {@code Builder}
87       */
88      @Nonnull
89      public static Builder newBuilder(boolean withDefaults) {
90          return new Builder(withDefaults);
91      }
92  
93      /**
94       * Creates a new {@code TrackableBase} builder instance using the specified object as a basis.
95       * Equivalent to {@code newBuilder(from, false)}.
96       *
97       * @param from the {@code TrackableBase} instance to use as a basis
98       * @return a new {@code Builder}
99       */
100     @Nonnull
101     public static Builder newBuilder(TrackableBase from) {
102         return newBuilder(from, false);
103     }
104 
105     /**
106      * Creates a new {@code TrackableBase} builder instance using the specified object as a basis.
107      *
108      * @param from the {@code TrackableBase} instance to use as a basis
109      * @param forceCopy the boolean indicating if a copy should be forced
110      * @return a new {@code Builder}
111      */
112     @Nonnull
113     public static Builder newBuilder(TrackableBase from, boolean forceCopy) {
114         return new Builder(from, forceCopy);
115     }
116 
117     /**
118      * Builder class used to create TrackableBase instances.
119      * @see #with()
120      * @see #newBuilder()
121      */
122     @NotThreadSafe
123     public static class Builder
124     {
125         TrackableBase base;
126 
127         Builder(boolean withDefaults) {
128             if (withDefaults) {
129             }
130         }
131 
132         Builder(TrackableBase base, boolean forceCopy) {
133             if (forceCopy) {
134             } else {
135                 this.base = base;
136             }
137         }
138 
139 
140         @Nonnull
141         public TrackableBase build() {
142             if (base != null
143             ) {
144                 return base;
145             }
146             return new TrackableBase(
147             );
148         }
149     }
150 
151 
152                 
153         public static final String USER_LEVEL = "user-level";
154         public static final String GLOBAL_LEVEL = "global-level";
155 
156         private String sourceLevel = USER_LEVEL;
157         private boolean sourceLevelSet = false;
158 
159         public void setSourceLevel( String sourceLevel )
160         {
161             if ( sourceLevelSet )
162             {
163                 throw new IllegalStateException( "Cannot reset sourceLevel attribute; it is already set to: " + sourceLevel );
164             }
165             else if ( !( USER_LEVEL.equals( sourceLevel ) || GLOBAL_LEVEL.equals( sourceLevel ) ) )
166             {
167                 throw new IllegalArgumentException( "sourceLevel must be one of: {" + USER_LEVEL + "," + GLOBAL_LEVEL + "}" );
168             }
169             else
170             {
171                 this.sourceLevel = sourceLevel;
172                 this.sourceLevelSet = true;
173             }
174         }
175 
176         public String getSourceLevel()
177         {
178             return sourceLevel;
179         }
180                 
181               
182 }