Package org.apache.sis.feature
Class CharacteristicMap
java.lang.Object
org.apache.sis.internal.util.AbstractMap<String,AbstractAttribute<?>>
org.apache.sis.feature.CharacteristicMap
- All Implemented Interfaces:
Cloneable
,Map<String,
AbstractAttribute<?>>
Implementation of
AbstractAttribute.characteristics()
map.
This map holds only the attribute characteristics which have been explicitly set or requested.- Since:
- 0.5
- Version:
- 0.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
An entry returned by theAbstractMap.entrySet()
iterator.Nested classes/interfaces inherited from class org.apache.sis.internal.util.AbstractMap
AbstractMap.EntryIterator<K,
V>, AbstractMap.IteratorAdapter<K, V>, AbstractMap.KeyIterator -
Field Summary
FieldsModifier and TypeFieldDescription(package private) AbstractAttribute<?>[]
Characteristics of thesource
attribute, created when first needed.private final AbstractAttribute
<?> The attribute source for which to provide characteristics.(package private) final CharacteristicTypeMap
Description of the attribute characteristics. -
Constructor Summary
ConstructorsConstructorDescriptionCharacteristicMap
(AbstractAttribute<?> source, CharacteristicTypeMap types) Creates an initially empty map of attribute characteristics. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
If no characteristic exists for the given name and that name is valid, creates a new map entry with a defaultAttribute
characteristic.protected boolean
addValue
(AbstractAttribute<?> value) Adds the given characteristic if none is currently associated for the same characteristic name.void
clear()
Removes all entries in this map.clone()
Returns a copy of this map.protected AbstractMap.EntryIterator
<String, AbstractAttribute<?>> Returns an iterator over the entries.Returns the attribute characteristic for the given name, ornull
if none.private int
Returns the index for the characteristic of the given name.boolean
isEmpty()
Returnsfalse
if this map contains at least one characteristic.put
(String key, AbstractAttribute<?> value) Sets the attribute characteristic for the given name.Removes the attribute characteristic for the given name.int
size()
Returns the number of attribute characteristics.(package private) final void
verifyAttributeType
(int index, DefaultAttributeType<?> type) Ensures that the given attribute type is the instance that we expect at the given index.Methods inherited from class org.apache.sis.internal.util.AbstractMap
containsKey, containsValue, entrySet, equals, getOrDefault, hashCode, keySet, putAll, 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, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
source
The attribute source for which to provide characteristics. -
characterizedBy
AbstractAttribute<?>[] characterizedByCharacteristics of thesource
attribute, created when first needed. -
types
Description of the attribute characteristics.
-
-
Constructor Details
-
CharacteristicMap
CharacteristicMap(AbstractAttribute<?> source, CharacteristicTypeMap types) Creates an initially empty map of attribute characteristics.- Parameters:
source
- the attribute which is characterized bycharacterizedBy
.types
- description of the characteristics ofsource
.
-
-
Method Details
-
clone
Returns a copy of this map. Characteristics are also cloned.- Overrides:
clone
in classObject
- Returns:
- a copy of this map.
- Throws:
CloneNotSupportedException
-
clear
public void clear()Removes all entries in this map.- Specified by:
clear
in interfaceMap<String,
AbstractAttribute<?>> - Overrides:
clear
in classAbstractMap<String,
AbstractAttribute<?>>
-
isEmpty
public boolean isEmpty()Returnsfalse
if this map contains at least one characteristic.- Specified by:
isEmpty
in interfaceMap<String,
AbstractAttribute<?>> - Overrides:
isEmpty
in classAbstractMap<String,
AbstractAttribute<?>> - Returns:
true
if this map contains no element.
-
size
public int size()Returns the number of attribute characteristics.- Specified by:
size
in interfaceMap<String,
AbstractAttribute<?>> - Overrides:
size
in classAbstractMap<String,
AbstractAttribute<?>>
-
get
Returns the attribute characteristic for the given name, ornull
if none.- Specified by:
get
in interfaceMap<String,
AbstractAttribute<?>>
-
remove
Removes the attribute characteristic for the given name.- Specified by:
remove
in interfaceMap<String,
AbstractAttribute<?>> - Overrides:
remove
in classAbstractMap<String,
AbstractAttribute<?>> - Parameters:
key
- the key of the entry to remove.- Returns:
- the previous value, or
null
if none.
-
indexOf
Returns the index for the characteristic of the given name.- Parameters:
key
- the name for which to get the characteristic index.- Returns:
- the index for the characteristic of the given name.
- Throws:
IllegalArgumentException
- if the given key is not the name of a characteristic in this map.
-
verifyAttributeType
Ensures that the given attribute type is the instance that we expect at the given index. If the given instance is not the expected one, then anIllegalArgumentException
will be thrown with an error message formatted using the name of expected and given types.- Parameters:
index
- index of the expected attribute type.type
- the actual attribute type.
-
put
Sets the attribute characteristic for the given name.- Specified by:
put
in interfaceMap<String,
AbstractAttribute<?>> - Overrides:
put
in classAbstractMap<String,
AbstractAttribute<?>> - Parameters:
key
- the name of the characteristic to set.value
- the value to associate to the given key.- Returns:
- the previous value, or
null
if none. - Throws:
IllegalArgumentException
- if the given key is not the name of a characteristic in this map.
-
addKey
If no characteristic exists for the given name and that name is valid, creates a new map entry with a defaultAttribute
characteristic.- Overrides:
addKey
in classAbstractMap<String,
AbstractAttribute<?>> - Parameters:
name
- the name of the characteristic to create, if it does not already exist.- Returns:
true
if a new characteristic has been created for the given name.- Throws:
IllegalArgumentException
- if the given key is not the name of a characteristic in this map.
-
addValue
Adds the given characteristic if none is currently associated for the same characteristic name.- Overrides:
addValue
in classAbstractMap<String,
AbstractAttribute<?>> - Parameters:
value
- the characteristic to add.- Returns:
true
if the characteristic has been added.- Throws:
IllegalArgumentException
- if given characteristic is not valid for this map.IllegalStateException
- if another characteristic already exists for the characteristic name.
-
entryIterator
Returns an iterator over the entries.- Specified by:
entryIterator
in classAbstractMap<String,
AbstractAttribute<?>> - Returns:
- an iterator over the entries in this map, or
null
.
-