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