Package com.github.owlcs.ontapi.config
Class ExtendedProperties
java.lang.Object
java.util.Dictionary<Object,Object>
java.util.Hashtable<Object,Object>
java.util.Properties
com.github.owlcs.ontapi.config.ExtendedProperties
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
This is a simple extended
Properties with supporting several primitive typed objects.
Currently, there are only 6 additional types:
It also supports a List consisting of the types listed above.
Example:
The following snippet
ExtendedProperties prop = new ExtendedProperties();
prop.setTypedProperty("key1", Stream.of(AccessMode.EXECUTE, AccessMode.READ).collect(Collectors.toCollection(ArrayList::new)));
prop.setTypedProperty("key2", false);
prop.setProperty("key3", "Some comment");
will produce the following properties file:
key1.list.enum.1=java.nio.file.AccessMode\#READ
key1.list.enum.0=java.nio.file.AccessMode\#EXECUTE
key2.boolean=false
key3=Some comment
Created by @ssz on 14.04.2017.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class java.util.Properties
defaults -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBooleanProperty(String key) Gets aBooleanthat corresponds the property record with the givenkey.Class<?> getClassProperty(String key) Gets aClassthat corresponds the property record with the givenkey.getDoubleProperty(String key) Gets aDoublethat corresponds the property record with the givenkey.Enum<?> getEnumProperty(String key) Gets aEnumthat corresponds the property record with the givenkey.getIntegerProperty(String key) Gets aIntegerthat corresponds the property record with the givenkey.List<?> getListProperty(String key) Gets aListif objects corresponding the givenkey.<T> List<T> getListProperty(String key, Class<T> type) Reads aListfrom thePropertiesMap.getLongProperty(String key) Gets aLongthat corresponds the property record with the givenkey.protected ExtendedProperties.MapTypegetMapType(Class<?> type) Gets aListif strings corresponding the givenkey.<T> TgetTypedProperty(String key, Class<T> type) Gets a typed Object value from thePropertiesMap.<T> voidsetListProperty(String key, List<T> values) Writes the given list to thePropertiesMap<T> voidsetTypedProperty(String key, T value) Puts the object of the typeExtendedPropertiesto thePropertiesMap.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
ExtendedProperties
public ExtendedProperties() -
ExtendedProperties
-
-
Method Details
-
getListProperty
Reads aListfrom thePropertiesMap. The keys in the Properties must be in the format "key.list.type.index", where "list" is a fixed delimiter, and "index" is an integer position of the element in the resultingList. -
getMapType
-
getTypedProperty
Gets a typed Object value from thePropertiesMap. The keys in the Properties must be in the formatkey.type. -
setTypedProperty
Puts the object of the typeExtendedPropertiesto thePropertiesMap. -
setListProperty
Writes the given list to thePropertiesMap -
getListProperty
Gets aListif objects corresponding the givenkey.- Parameters:
key- String, notnull- Returns:
Listwith uncertain generic type
-
getStringListProperty
Gets aListif strings corresponding the givenkey.- Parameters:
key- String, notnull- Returns:
ListofStrings
-
getClassProperty
Gets aClassthat corresponds the property record with the givenkey.- Parameters:
key- String, notnull- Returns:
Class
-
getEnumProperty
Gets aEnumthat corresponds the property record with the givenkey.- Parameters:
key- String, notnull- Returns:
Enum
-
getBooleanProperty
Gets aBooleanthat corresponds the property record with the givenkey.- Parameters:
key- String, notnull- Returns:
- boolean
-
getIntegerProperty
Gets aIntegerthat corresponds the property record with the givenkey.- Parameters:
key- String, notnull- Returns:
- int
-
getLongProperty
Gets aLongthat corresponds the property record with the givenkey.- Parameters:
key- String, notnull- Returns:
- long
-
getDoubleProperty
Gets aDoublethat corresponds the property record with the givenkey.- Parameters:
key- String, notnull- Returns:
- double
-