org.openl.config.ReadOnlyPropertiesHolder Maven / Gradle / Ivy
The newest version!
package org.openl.config;
import java.util.Map;
import org.springframework.core.env.PropertyResolver;
public class ReadOnlyPropertiesHolder implements PropertiesHolder {
protected PropertyResolver propertyResolver;
public ReadOnlyPropertiesHolder(PropertyResolver propertyResolver) {
this.propertyResolver = propertyResolver;
}
@Override
public PropertyResolver getPropertyResolver() {
return propertyResolver;
}
@Override
public final String getProperty(String key) {
return doGetProperty(key);
}
@Override
public final void setProperty(String key, Object value) {
String propValue = value != null ? value.toString() : null;
doSetProperty(key, propValue);
}
protected String doGetProperty(String key) {
return propertyResolver.getProperty(key);
}
protected void doSetProperty(String key, String value) {
throw new UnsupportedOperationException("Editing is not supported");
}
@Override
public void revertProperties(String... keys) {
throw new UnsupportedOperationException("Editing is not supported");
}
@Override
public Map getConfig() {
throw new UnsupportedOperationException("Editing is not supported");
}
}