config-persister-impl: final parameters
[controller.git] / opendaylight / config / config-persister-impl / src / main / java / org / opendaylight / controller / config / persist / impl / PropertiesProviderAdapterImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.config.persist.impl;
9
10 import org.opendaylight.controller.config.persist.api.PropertiesProvider;
11
12 public class PropertiesProviderAdapterImpl implements PropertiesProvider {
13     private final PropertiesProvider inner;
14     private final String index;
15
16     public PropertiesProviderAdapterImpl(final PropertiesProvider inner, final String index) {
17         this.inner = inner;
18         this.index = index;
19     }
20
21     @Override
22     public String getProperty(final String key) {
23         String fullKey = getFullKeyForReporting(key);
24         return inner.getPropertyWithoutPrefix(fullKey);
25     }
26
27     public String getPrefix() {
28         return inner.getPrefix() + "." + index + ".properties";
29     }
30
31     @Override
32     public String getPropertyWithoutPrefix(final String fullKey) {
33         return inner.getPropertyWithoutPrefix(fullKey);
34     }
35
36
37     @Override
38     public String getFullKeyForReporting(final String key) {
39         return getPrefix()  + "." + key;
40     }
41 }