View Javadoc

1   /*
2    * Copyright 2012-2013 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.properties.impl.config.ds;
17  
18  import de.smartics.util.lang.BlankArgumentException;
19  
20  /**
21   * Helper to create instances of {@link TenentUserConfigurationKey}.
22   */
23  public final class DataSourceConfigurationBuilder
24  { // NOPMD
25    // ********************************* Fields *********************************
26  
27    // --- constants ------------------------------------------------------------
28  
29    // --- members --------------------------------------------------------------
30  
31    /**
32     * The source of the data source configuration.
33     *
34     * @serial
35     */
36    private String configSourceId;
37  
38    /**
39     * The name of the data source to lookup in a JNDI context.
40     *
41     * @serial
42     */
43    private String jndiName;
44  
45    /**
46     * The flag to drop the configuration table if set to <code>true</code>.
47     *
48     * @serial
49     */
50    private boolean dropTable;
51  
52    /**
53     * The flag to create the configuration if set to <code>true</code>.
54     *
55     * @serial
56     */
57    private boolean createTable;
58  
59    // ****************************** Initializer *******************************
60  
61    // ****************************** Constructors ******************************
62  
63    // ****************************** Inner Classes *****************************
64  
65    // ********************************* Methods ********************************
66  
67    // --- init -----------------------------------------------------------------
68  
69    // --- get&set --------------------------------------------------------------
70  
71    /**
72     * Returns the source of the data source configuration.
73     *
74     * @return the source of the data source configuration.
75     */
76    public String getConfigSourceId()
77    {
78      return configSourceId;
79    }
80  
81    /**
82     * Sets the source of the data source configuration.
83     *
84     * @param configSourceId the source of the data source configuration.
85     */
86    public void setConfigSourceId(final String configSourceId)
87    {
88      this.configSourceId = configSourceId;
89    }
90  
91    /**
92     * Sets the name of the data source to lookup in a JNDI context.
93     *
94     * @param jndiName the name of the data source to lookup in a JNDI context.
95     */
96    public void setJndiName(final String jndiName)
97    {
98      this.jndiName = jndiName;
99    }
100 
101   /**
102    * Sets the flag to drop the configuration table if set to <code>true</code>.
103    *
104    * @param dropTable the flag to drop the configuration table if set to
105    *          <code>true</code>.
106    */
107   public void setDropTable(final boolean dropTable)
108   {
109     this.dropTable = dropTable;
110   }
111 
112   /**
113    * Sets the flag to create the configuration if set to <code>true</code>.
114    *
115    * @param createTable the flag to create the configuration if set to
116    *          <code>true</code>.
117    */
118   public void setCreateTable(final boolean createTable)
119   {
120     this.createTable = createTable;
121   }
122 
123   /**
124    * Returns the name of the data source to lookup in a JNDI context.
125    *
126    * @return the name of the data source to lookup in a JNDI context.
127    */
128   public String getJndiName()
129   {
130     return jndiName;
131   }
132 
133   /**
134    * Returns the flag to drop the configuration table if set to
135    * <code>true</code>.
136    *
137    * @return the flag to drop the configuration table if set to
138    *         <code>true</code>.
139    */
140   public boolean isDropTable()
141   {
142     return dropTable;
143   }
144 
145   /**
146    * Returns the flag to create the configuration if set to <code>true</code>.
147    *
148    * @return the flag to create the configuration if set to <code>true</code>.
149    */
150   public boolean isCreateTable()
151   {
152     return createTable;
153   }
154 
155   // --- business -------------------------------------------------------------
156 
157   /**
158    * Creates an {@link DataSourceConfiguration} instance.
159    *
160    * @return an {@link DataSourceConfiguration} instance.
161    * @throws BlankArgumentException if the {@code jndiName}, {@code createTable}
162    *           or {@code dropTable} are blank.
163    */
164   public DataSourceConfiguration build() throws BlankArgumentException
165   {
166     return new DataSourceConfiguration(configSourceId, jndiName, dropTable,
167         createTable);
168   }
169 
170   // --- object basics --------------------------------------------------------
171 
172 }