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.cache;
17
18 import de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement;
19 import de.smartics.properties.api.config.domain.SerializableConfigurationPropertiesManagement;
20 import de.smartics.properties.spi.config.support.ConfigurationPropertiesManagementSpi;
21 import de.smartics.properties.spi.config.support.SerializableConfigurationPropertiesManagementSpi;
22 import de.smartics.util.lang.Arguments;
23
24 /**
25 * A delegate that provides a cache.
26 */
27 public final class CacheConfigurationPropertiesManagement extends
28 AbstractCacheConfigurationPropertiesManagement implements
29 ConfigurationPropertiesManagement
30 {
31 // ********************************* Fields *********************************
32
33 // --- constants ------------------------------------------------------------
34
35 // --- members --------------------------------------------------------------
36
37 /**
38 * The class version identifier.
39 */
40 private static final long serialVersionUID = 1L;
41
42 /**
43 * The wrapped delegate whose properties are to be cached.
44 */
45 private final ConfigurationPropertiesManagementSpi delegate;
46
47 // ****************************** Initializer *******************************
48
49 // ****************************** Constructors ******************************
50
51 /**
52 * Default constructor.
53 *
54 * @param delegate the wrapped delegate whose properties are to be cached.
55 * @throws NullPointerException if {@code delegate} is <code>null</code>.
56 */
57 public CacheConfigurationPropertiesManagement(
58 final ConfigurationPropertiesManagementSpi delegate)
59 throws NullPointerException
60 {
61 Arguments.checkNotNull("delegate", delegate);
62 this.delegate = delegate;
63 }
64
65 // ****************************** Inner Classes *****************************
66
67 // ********************************* Methods ********************************
68
69 // --- init -----------------------------------------------------------------
70
71 // --- get&set --------------------------------------------------------------
72
73 @Override
74 protected ConfigurationPropertiesManagementSpi getDelegate()
75 {
76 return delegate;
77 }
78
79 // --- business -------------------------------------------------------------
80
81 @Override
82 public SerializableConfigurationPropertiesManagement toSerializable()
83 {
84 return new SerializableCacheConfigurationPropertiesManagement(
85 (SerializableConfigurationPropertiesManagementSpi) delegate
86 .toSerializable(),
87 getCache());
88 }
89
90 // --- object basics --------------------------------------------------------
91
92 }