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 class
View of the entries contained in the map.private final class
The iterator over theValueMap.Property
elements contained in anValueMap.Entries
set.(package private) final class
A 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 Object
The metadata object to wrap.(package private) final ValueExistencePolicy
The 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 TypeMethodDescriptionboolean
containsKey
(Object key) Returnstrue
if 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, ornull
if this map contains no mapping for the key.boolean
isEmpty()
Returnstrue
if 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.void
Puts 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.int
size()
Returns the number of elements in this map.Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, keySet, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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()Returnstrue
if this map contains no key-value mappings. -
size
public int size()Returns the number of elements in this map. -
containsKey
Returnstrue
if this map contains a mapping for the specified key.- Specified by:
containsKey
in interfaceMap<String,
Object> - Overrides:
containsKey
in classPropertyMap<Object>
-
get
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key. -
put
Associates the specified value with the specified key in this map.- Specified by:
put
in interfaceMap<String,
Object> - Overrides:
put
in 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:
putAll
in interfaceMap<String,
Object> - Overrides:
putAll
in 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:
remove
in interfaceMap<String,
Object> - Overrides:
remove
in 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:
iterator
in classPropertyMap<Object>
-