1 /* Copyright (c) 2008 Sascha Kohlmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU Affero General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 package net.sf.eos.config;
17
18 /**
19 * Support class for configurable objects.
20 * @author Sascha Kohlmann
21 */
22 public abstract class Configured implements Configurable {
23
24 private Configuration config;
25
26 /** Construct a Configured. */
27 public Configured() {
28 super();
29 }
30
31 /**
32 * Creates a copy of the given {@code Configuration} and stores it in
33 * a manner that {@link #getConfiguration()} can reach it.
34 * <p>If override the method first call {@code super} in the
35 * overriding method.</p>
36 * @param config the {@code Configuration} to copy.
37 */
38 public void configure(
39 @SuppressWarnings("hiding") final Configuration config) {
40 this.config = new Configuration(config);
41 }
42
43 /**
44 * Returns the configuration.
45 * @return the configuration holder or {@code null}
46 */
47 protected final Configuration getConfiguration() {
48 return this.config;
49 }
50 }