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