View Javadoc

1   /*
2    * Copyright 2012 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.ci.config.load;
17  
18  
19  /**
20   * Controls the loading and creation of Hudson job configuration files.
21   */
22  public final class HudsonJobConfigurationLoaderConfig
23  {
24    // ********************************* Fields *********************************
25  
26    // --- constants ------------------------------------------------------------
27  
28    // --- members --------------------------------------------------------------
29  
30    /**
31     * The flag to control whether the <code>scm</code> element is to be added to
32     * the generated Job <code>config.xml</code> with full content. The
33     * <code>scm</code> is an element in addition to the SCM configuration as an
34     * entry in the same document.
35     * <p>
36     * In some documents the element is expected to be stated redundantly. Some
37     * configurations allow to reference the SCM information of an entry element
38     * with an XPath expression. Adding an element with that expression is
39     * <strong>not</strong> controllable with this flag.
40     * </p>
41     */
42    private final boolean addScmElementWithFullContent;
43  
44    /**
45     * The flag to control the removal of the <code>cascadingChildrenNames</code>
46     * element from the job configuration.
47     * <p>
48     * The element is added by Hudson if the <code>config.xml</code> is retrieved.
49     * The presence of the element rejects the configuration from being pushed on
50     * the server.
51     * </p>
52     */
53    private final boolean removeCascadingChildrenNamesElement;
54  
55    /**
56     * The flag to control the removal of the
57     * <code>cascading-job-properties</code> element from the job configuration.
58     * <p>
59     * The element is added by Hudson if the <code>config.xml</code> is retrieved.
60     * The presence of the element rejects the configuration from being pushed on
61     * the server.
62     * </p>
63     */
64    private final boolean removeCascadingJobPropertiesElement;
65  
66    // ****************************** Initializer *******************************
67  
68    // ****************************** Constructors ******************************
69  
70    /**
71     * Builder pattern.
72     *
73     * @param builder the builder with the information to initialize the instance.
74     */
75    private HudsonJobConfigurationLoaderConfig(final Builder builder)
76    {
77      this.addScmElementWithFullContent = builder.addScmElementWithFullContent;
78      this.removeCascadingChildrenNamesElement =
79          builder.removeCascadingChildrenNamesElement;
80      this.removeCascadingJobPropertiesElement =
81          builder.removeCascadingJobPropertiesElement;
82    }
83  
84    // ****************************** Inner Classes *****************************
85  
86    /**
87     * Builder to help adding properties to the configuration instance.
88     */
89    public static final class Builder
90    {
91      // ******************************** Fields ********************************
92  
93      // --- constants ----------------------------------------------------------
94  
95      // --- members ------------------------------------------------------------
96  
97      /**
98       * The flag to control whether the <code>scm</code> element is to be added
99       * to the generated Job <code>config.xml</code> with full content. The
100      * <code>scm</code> is an element in addition to the SCM configuration as an
101      * entry in the same document.
102      * <p>
103      * In some documents the element is expected to be stated redundantly. Some
104      * configurations allow to reference the SCM information of an entry element
105      * with an XPath expression. Adding an element with that expression is
106      * <strong>not</strong> controllable with this flag.
107      * </p>
108      */
109     private boolean addScmElementWithFullContent;
110 
111     /**
112      * The flag to control the removal of the
113      * <code>cascadingChildrenNames</code> element from the job configuration.
114      * <p>
115      * The element is added by Hudson if the <code>config.xml</code> is
116      * retrieved. The presence of the element rejects the configuration from
117      * being pushed on the server.
118      * </p>
119      */
120     private boolean removeCascadingChildrenNamesElement;
121 
122     /**
123      * The flag to control the removal of the
124      * <code>cascading-job-properties</code> element from the job configuration.
125      * <p>
126      * The element is added by Hudson if the <code>config.xml</code> is
127      * retrieved. The presence of the element rejects the configuration from
128      * being pushed on the server.
129      * </p>
130      */
131     private boolean removeCascadingJobPropertiesElement;
132 
133     // ***************************** Initializer ******************************
134 
135     // ***************************** Constructors *****************************
136 
137     /**
138      * Sets the flag to control whether the <code>scm</code> element is to be
139      * added to the generated Job <code>config. xml</code> with full content.
140      * The <code>scm</code> is an element in addition to the SCM configuration
141      * as an entry in the same document.
142      * <p>
143      * In some documents the element is expected to be stated redundantly. Some
144      * configurations allow to reference the SCM information of an entry element
145      * with an XPath expression. Adding an element with that expression is
146      * <strong>not</strong> controllable with this flag.
147      * </p>
148      *
149      * @param addScmElementWithFullContent the flag to control whether the
150      *          <code>scm</code> element is to be added to the generated Job
151      *          <code>config</code>.
152      * @return a reference to this builder.
153      */
154     public Builder withAddScmElementWithFullContent(
155         final boolean addScmElementWithFullContent)
156     {
157       this.addScmElementWithFullContent = addScmElementWithFullContent;
158       return this;
159     }
160 
161     /**
162      * Sets the flag to control the removal of the
163      * <code>cascadingChildrenNames</code> element from the job configuration.
164      * <p>
165      * The element is added by Hudson if the <code>config.xml</code> is
166      * retrieved. The presence of the element rejects the configuration from
167      * being pushed on the server.
168      * </p>
169      *
170      * @param removeCascadingChildrenNamesElement the flag to control the
171      *          removal of the <code>cascadingChildrenNames</code> element from
172      *          the job configuration.
173      * @return a reference to this builder.
174      */
175     public Builder withRemoveCascadingChildrenNamesElement(
176         final boolean removeCascadingChildrenNamesElement)
177     {
178       this.removeCascadingChildrenNamesElement =
179           removeCascadingChildrenNamesElement;
180       return this;
181     }
182 
183     /**
184      * Sets the flag to control the removal of the
185      * <code>cascading-job-properties</code> element from the job configuration.
186      * <p>
187      * The element is added by Hudson if the <code>config.xml</code> is
188      * retrieved. The presence of the element rejects the configuration from
189      * being pushed on the server.
190      * </p>
191      *
192      * @param removeCascadingJobPropertiesElement the flag to control the
193      *          removal of the <code>cascading-job-properties</code> element
194      *          from the job configuration.
195      * @return a reference to this builder.
196      */
197     public Builder withRemoveCascadingJobPropertiesElement(
198         final boolean removeCascadingJobPropertiesElement)
199     {
200       this.removeCascadingJobPropertiesElement =
201           removeCascadingJobPropertiesElement;
202       return this;
203     }
204 
205     /**
206      * Creates the instance configured by this builder.
207      *
208      * @return the instance configured by this builder.
209      */
210     public HudsonJobConfigurationLoaderConfig build()
211     {
212       return new HudsonJobConfigurationLoaderConfig(this);
213     }
214 
215     // ***************************** Inner Classes ****************************
216 
217     // ******************************** Methods *******************************
218 
219     // --- init ---------------------------------------------------------------
220 
221     // --- get&set ------------------------------------------------------------
222 
223     // --- business -----------------------------------------------------------
224 
225     // --- object basics ------------------------------------------------------
226   }
227 
228   // ********************************* Methods ********************************
229 
230   // --- init -----------------------------------------------------------------
231 
232   // --- get&set --------------------------------------------------------------
233 
234   /**
235    * Returns the flag to control whether the <code>scm</code> element is to be
236    * added to the generated Job <code>config. xml</code> with full content. The
237    * <code>scm</code> is an element in addition to the SCM configuration as an
238    * entry in the same document.
239    * <p>
240    * In some documents the element is expected to be stated redundantly. Some
241    * configurations allow to reference the SCM information of an entry element
242    * with an XPath expression. Adding an element with that expression is
243    * <strong>not</strong> controllable with this flag.
244    * </p>
245    *
246    * @return the flag to control whether the <code>scm</code> element is to be
247    *         added to the generated Job <code>config</code>.
248    */
249   public boolean isAddScmElementWithFullContent()
250   {
251     return addScmElementWithFullContent;
252   }
253 
254   /**
255    * Returns the flag to control the removal of the
256    * <code>cascadingChildrenNames</code> element from the job configuration.
257    * <p>
258    * The element is added by Hudson if the <code>config.xml</code> is retrieved.
259    * The presence of the element rejects the configuration from being pushed on
260    * the server.
261    * </p>
262    *
263    * @return the flag to control the removal of the
264    *         <code>cascadingChildrenNames</code> element from the job
265    *         configuration.
266    */
267   public boolean isRemoveCascadingChildrenNamesElement()
268   {
269     return removeCascadingChildrenNamesElement;
270   }
271 
272   /**
273    * Returns the flag to control the removal of the
274    * <code>cascading-job-properties</code> element from the job configuration.
275    * <p>
276    * The element is added by Hudson if the <code>config.xml</code> is retrieved.
277    * The presence of the element rejects the configuration from being pushed on
278    * the server.
279    * </p>
280    *
281    * @return the flag to control the removal of the
282    *         <code>cascading-job-properties</code> element from the job
283    *         configuration.
284    */
285   public boolean isRemoveCascadingJobPropertiesElement()
286   {
287     return removeCascadingJobPropertiesElement;
288   }
289 
290   // --- business -------------------------------------------------------------
291 
292   // --- object basics --------------------------------------------------------
293 }