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.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   * This is the property specification used to activate a profile. If the value field is empty,
20   * then the existence of the named property will activate the profile, otherwise it does a case-sensitive
21   * match against the property value as well.
22   */
23  @Experimental
24  @Generated @ThreadSafe @Immutable
25  public class ActivationProperty
26      implements Serializable
27  {
28      /**
29       * The name of the property to be used to activate a profile.
30       */
31      final String name;
32      /**
33       * The value of the property to be used to activate a profile.
34       */
35      final String value;
36  
37      /**
38        * Constructor for this class, package protected.
39        * @see Builder#build()
40        */
41      ActivationProperty(
42          String name,
43          String value
44      )
45      {
46          this.name = name;
47          this.value = value;
48      }
49  
50      /**
51       * The name of the property to be used to activate a profile.
52       *
53       * @return a {@code String}
54       */
55      public String getName()
56      {
57          return this.name;
58      }
59  
60      /**
61       * The value of the property to be used to activate a profile.
62       *
63       * @return a {@code String}
64       */
65      public String getValue()
66      {
67          return this.value;
68      }
69  
70      /**
71       * Creates a new builder with this object as the basis.
72       *
73       * @return a {@code Builder}
74       */
75      @Nonnull
76      public Builder with()
77      {
78          return newBuilder( this );
79      }
80      /**
81       * Creates a new {@code ActivationProperty} instance using the specified name.
82       *
83       * @param name the new {@code String} to use
84       * @return a {@code ActivationProperty} with the specified name
85       */
86      @Nonnull
87      public ActivationProperty withName( String name )
88      {
89          return with().name( name ).build();
90      }
91      /**
92       * Creates a new {@code ActivationProperty} instance using the specified value.
93       *
94       * @param value the new {@code String} to use
95       * @return a {@code ActivationProperty} with the specified value
96       */
97      @Nonnull
98      public ActivationProperty withValue( String value )
99      {
100         return with().value( value ).build();
101     }
102 
103     /**
104      * Creates a new {@code ActivationProperty} instance.
105      * Equivalent to {@code newInstance( true )}.
106      * @see #newInstance(boolean)
107      *
108      * @return a new {@code ActivationProperty}
109      */
110     @Nonnull
111     public static ActivationProperty newInstance()
112     {
113         return newInstance( true );
114     }
115 
116     /**
117      * Creates a new {@code ActivationProperty} instance using default values or not.
118      * Equivalent to {@code newBuilder( withDefaults ).build()}.
119      *
120      * @param withDefaults the boolean indicating whether default values should be used
121      * @return a new {@code ActivationProperty}
122      */
123     @Nonnull
124     public static ActivationProperty newInstance( boolean withDefaults )
125     {
126         return newBuilder( withDefaults ).build();
127     }
128 
129     /**
130      * Creates a new {@code ActivationProperty} builder instance.
131      * Equivalent to {@code newBuilder( true )}.
132      * @see #newBuilder(boolean)
133      *
134      * @return a new {@code Builder}
135      */
136     @Nonnull
137     public static Builder newBuilder()
138     {
139         return newBuilder( true );
140     }
141 
142     /**
143      * Creates a new {@code ActivationProperty} builder instance using default values or not.
144      *
145      * @param withDefaults the boolean indicating whether default values should be used
146      * @return a new {@code Builder}
147      */
148     @Nonnull
149     public static Builder newBuilder( boolean withDefaults )
150     {
151         return new Builder( withDefaults );
152     }
153 
154     /**
155      * Creates a new {@code ActivationProperty} builder instance using the specified object as a basis.
156      * Equivalent to {@code newBuilder( from, false )}.
157      *
158      * @param from the {@code ActivationProperty} instance to use as a basis
159      * @return a new {@code Builder}
160      */
161     @Nonnull
162     public static Builder newBuilder( ActivationProperty from )
163     {
164         return newBuilder( from, false );
165     }
166 
167     /**
168      * Creates a new {@code ActivationProperty} builder instance using the specified object as a basis.
169      *
170      * @param from the {@code ActivationProperty} instance to use as a basis
171      * @param forceCopy the boolean indicating if a copy should be forced
172      * @return a new {@code Builder}
173      */
174     @Nonnull
175     public static Builder newBuilder( ActivationProperty from, boolean forceCopy )
176     {
177         return new Builder( from, forceCopy );
178     }
179 
180     /**
181      * Builder class used to create ActivationProperty instances.
182      * @see #with()
183      * @see #newBuilder()
184      */
185     @NotThreadSafe
186     public static class Builder
187     {
188         ActivationProperty base;
189         String name;
190         String value;
191 
192         Builder( boolean withDefaults )
193         {
194             if ( withDefaults )
195             {
196             }
197         }
198 
199         Builder( ActivationProperty base, boolean forceCopy )
200         {
201             if ( forceCopy )
202             {
203                 this.name = base.name;
204                 this.value = base.value;
205             }
206             else
207             {
208                 this.base = base;
209             }
210         }
211 
212         @Nonnull
213         public Builder name( String name )
214         {
215             this.name = name;
216             return this;
217         }
218 
219         @Nonnull
220         public Builder value( String value )
221         {
222             this.value = value;
223             return this;
224         }
225 
226 
227         @Nonnull
228         public ActivationProperty build()
229         {
230             if ( base != null
231                     && ( name == null || name == base.name )
232                     && ( value == null || value == base.value )
233             )
234             {
235                 return base;
236             }
237             return new ActivationProperty(
238                 name != null ? name : ( base != null ? base.name : null ),
239                 value != null ? value : ( base != null ? base.value : null )
240             );
241         }
242     }
243 
244 }