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.spi.config.ds; 17 18 19 /** 20 * Helper to create database configurations with a data source. 21 */ 22 public abstract class AbstractDataSourceDescriptor implements 23 PropertiesDataSourceDescriptor 24 { 25 // ********************************* Fields ********************************* 26 27 // --- constants ------------------------------------------------------------ 28 29 /** 30 * The class version identifier. 31 */ 32 private static final long serialVersionUID = 1L; 33 34 // --- members -------------------------------------------------------------- 35 36 /** 37 * The name of the configuration table. 38 */ 39 private final String table; 40 41 /** 42 * The name of the property name column. 43 */ 44 private final String nameColumn; 45 46 /** 47 * The name of the property value column. 48 */ 49 private final String valueColumn; 50 51 // ****************************** Initializer ******************************* 52 53 // ****************************** Constructors ****************************** 54 55 /** 56 * Default constructor. 57 * 58 * @param builder the builder of descriptor instances. 59 */ 60 protected AbstractDataSourceDescriptor(final Builder builder) 61 { 62 this.table = builder.table; 63 this.nameColumn = builder.nameColumn; 64 this.valueColumn = builder.valueColumn; 65 } 66 67 // ****************************** Inner Classes ***************************** 68 69 /** 70 * The builder of descriptor instances. 71 */ 72 public static class Builder 73 { 74 // ******************************** Fields ******************************** 75 76 // --- constants ---------------------------------------------------------- 77 78 // --- members ------------------------------------------------------------ 79 80 /** 81 * The name of the configuration table. 82 */ 83 private String table = "config"; 84 85 /** 86 * The name of the property name column. 87 */ 88 private String nameColumn = "name"; 89 90 /** 91 * The name of the property value column. 92 */ 93 private String valueColumn = "value"; 94 95 // ***************************** Initializer ****************************** 96 97 // ***************************** Constructors ***************************** 98 99 // ***************************** Inner Classes **************************** 100 101 // ******************************** Methods ******************************* 102 103 // --- init --------------------------------------------------------------- 104 105 // --- get&set ------------------------------------------------------------ 106 107 /** 108 * Sets the name of the configuration table. 109 * 110 * @param table the name of the configuration table. 111 */ 112 public final void setTable(final String table) 113 { 114 this.table = table; 115 } 116 117 /** 118 * Sets the name of the property name column. 119 * 120 * @param nameColumn the name of the property name column. 121 */ 122 public final void setNameColumn(final String nameColumn) 123 { 124 this.nameColumn = nameColumn; 125 } 126 127 /** 128 * Sets the name of the property value column. 129 * 130 * @param valueColumn the name of the property value column. 131 */ 132 public final void setValueColumn(final String valueColumn) 133 { 134 this.valueColumn = valueColumn; 135 } 136 137 // --- business ----------------------------------------------------------- 138 139 // --- object basics ------------------------------------------------------ 140 141 } 142 143 // ********************************* Methods ******************************** 144 145 // --- init ----------------------------------------------------------------- 146 147 // --- get&set -------------------------------------------------------------- 148 149 /** 150 * Returns the name of the configuration table. 151 * 152 * @return the name of the configuration table. 153 */ 154 @Override 155 public final String getTable() 156 { 157 return table; 158 } 159 160 /** 161 * Returns the name of the property name column. 162 * 163 * @return the name of the property name column. 164 */ 165 @Override 166 public final String getNameColumn() 167 { 168 return nameColumn; 169 } 170 171 /** 172 * Returns the name of the property value column. 173 * 174 * @return the name of the property value column. 175 */ 176 @Override 177 public final String getValueColumn() 178 { 179 return valueColumn; 180 } 181 182 // --- business ------------------------------------------------------------- 183 184 // --- object basics -------------------------------------------------------- 185 186 }