Package org.apache.sis.metadata
Class ValueMap
A view of a metadata object as a map. Keys are property names and values
are the value returned by the
getFoo() method using reflection.- Since:
- 0.3
- Version:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classView of the entries contained in the map.private final classThe iterator over theValueMap.Propertyelements contained in anValueMap.Entriesset.(package private) final classA map entry for a given property.Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ObjectThe metadata object to wrap.(package private) final ValueExistencePolicyThe behavior of this map toward null or empty values.Fields inherited from class org.apache.sis.metadata.PropertyMap
accessor, entrySet, keyPolicy -
Constructor Summary
ConstructorsConstructorDescriptionValueMap(Object metadata, PropertyAccessor accessor, KeyNamePolicy keyPolicy, ValueExistencePolicy valuePolicy) Creates a map of values for the specified metadata and accessor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) Returnstrueif this map contains a mapping for the specified key.entrySet()Returns a view of the mappings contained in this map.Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.booleanisEmpty()Returnstrueif this map contains no key-value mappings.iterator()Returns an iterator over the entries contained in this map.Associates the specified value with the specified key in this map.voidPuts every entries from the given map.putIfAbsent(String key, Object value) Associates the specified value with the specified key in this map if no value is currently associated.Removes the mapping for a key from this map if it is present.intsize()Returns the number of elements in this map.Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, keySet, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, remove, replace, replace, replaceAll
-
Field Details
-
metadata
The metadata object to wrap. -
valuePolicy
The behavior of this map toward null or empty values.
-
-
Constructor Details
-
ValueMap
ValueMap(Object metadata, PropertyAccessor accessor, KeyNamePolicy keyPolicy, ValueExistencePolicy valuePolicy) Creates a map of values for the specified metadata and accessor.- Parameters:
metadata- the metadata object to wrap.accessor- the accessor to use for the metadata.keyPolicy- determines the string representation of keys in the map..valuePolicy- the behavior of this map toward null or empty values.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrueif this map contains no key-value mappings. -
size
public int size()Returns the number of elements in this map. -
containsKey
Returnstrueif this map contains a mapping for the specified key.- Specified by:
containsKeyin interfaceMap<String,Object> - Overrides:
containsKeyin classPropertyMap<Object>
-
get
Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key. -
put
Associates the specified value with the specified key in this map.- Specified by:
putin interfaceMap<String,Object> - Overrides:
putin classAbstractMap<String,Object> - Throws:
IllegalArgumentException- if the given key is not the name of a property in the metadata.ClassCastException- if the given value is not of the expected type.UnmodifiableMetadataException- if the property for the given key is read-only.
-
putIfAbsent
Associates the specified value with the specified key in this map if no value is currently associated.- Throws:
IllegalArgumentException- if the given key is not the name of a property in the metadata.ClassCastException- if the given value is not of the expected type.UnmodifiableMetadataException- if the property for the given key is read-only.
-
putAll
Puts every entries from the given map. This method is overloaded for performance reasons since we are not interested in the return value of theput(String, Object)method.- Specified by:
putAllin interfaceMap<String,Object> - Overrides:
putAllin classAbstractMap<String,Object> - Throws:
IllegalArgumentException- if at least one key is not the name of a property in the metadata.ClassCastException- if at least one value is not of the expected type.UnmodifiableMetadataException- if at least one property is read-only.
-
remove
Removes the mapping for a key from this map if it is present.- Specified by:
removein interfaceMap<String,Object> - Overrides:
removein classAbstractMap<String,Object> - Throws:
UnmodifiableMetadataException- if the property for the given key is read-only.UnsupportedOperationException
-
entrySet
Returns a view of the mappings contained in this map. -
iterator
Returns an iterator over the entries contained in this map.- Specified by:
iteratorin classPropertyMap<Object>
-