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