Configuration2
interface extends Configuration
, so a class which implements Configuration2
is a Configuration
Configuration2
interface provide a framework to define your properties and their types, and handle getting and setting these properties, and the serializing and unserializing of the configuration.
getPropertyValueAsXXX(String)
allow to get the value of a property in any of the default supported types.
public class MyConfiguration implements Configuration2 { public static final String MY_INT_PROPERTY = "MyIntProperty"; private static final SortedMap<String, Class<?>> properties = new TreeMap<>(); static { properties.put(MY_INT_PROPERTY, Integer.Type); } private int intPropValue = 0; public SortedMap<String, Class<?>> getPropertiesTypes() { return properties; } public void setPropertyValue(String key, Object value) { if (key.equals(MY_INT_PROPERTY) && value instanceof Integer) { intPropValue = (Integer)value; } } public Object getPropertyValue(String key) { if (key.equals(MY_INT_PROPERTY)) { return intPropValue; } else { return null; } } }
Configuration2
interface extends Configuration
, so a class which implements Configuration2
is a Configuration
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences