Package org.apache.sis.internal.jaxb
Class IdentifierMapAdapter.Iter
java.lang.Object
java.util.AbstractMap<org.opengis.metadata.citation.Citation,Boolean>
java.util.HashMap<org.opengis.metadata.citation.Citation,Boolean>
org.apache.sis.internal.jaxb.IdentifierMapAdapter.Iter
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterator<Map.Entry<org.opengis.metadata.citation.Citation,
,String>> Map<org.opengis.metadata.citation.Citation,
Boolean>
- Enclosing class:
IdentifierMapAdapter
private static final class IdentifierMapAdapter.Iter
extends HashMap<org.opengis.metadata.citation.Citation,Boolean>
implements Iterator<Map.Entry<org.opengis.metadata.citation.Citation,String>>
The iterator over the (citation, code) entries. This iterator is created by the
HashMap.entrySet()
collection. It extends HashMap
as an opportunist implementation strategy,
but users do not need to know this detail.
This iterator supports the remove()
operation if the underlying collection supports it.
The map entries are used as a safety against duplicated authority values. The map values
are non-null only after we iterated over an authority. Then the value is Boolean.TRUE
if the identifier has been removed, of Boolean#FALSE
otherwise.
- Since:
- 0.3
- Version:
- 0.7
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.opengis.metadata.citation.Citation
The current authority.private Iterator
<? extends org.opengis.metadata.Identifier> An iterator over theIdentifierMapAdapter.identifiers
collection, or (@code null} if we have reached the iteration end.private final boolean
true
if the iterator should support theremove()
operation.The next entry to be returned bynext()
, ornull
if not yet computed. -
Constructor Summary
ConstructorsConstructorDescriptionIter
(Collection<? extends org.opengis.metadata.Identifier> identifiers, boolean isModifiable) Creates a new iterator for the given collection of identifiers. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Iterators are not intended to be cloned.boolean
hasNext()
If we need to search for the next element, fetches it now.next()
If we need to search for the next element, searches it now.void
remove()
Removes the last element returned bynext()
.private void
toNext()
Advances to the next non-null identifier, skips duplicated authorities, wraps the identifier in an entry if needed and stores the result in thenext
field.toString()
Returns the next value to be returned, for debugging purpose only.Methods inherited from class java.util.HashMap
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
identifiers
An iterator over theIdentifierMapAdapter.identifiers
collection, or (@code null} if we have reached the iteration end. -
next
-
authority
private transient org.opengis.metadata.citation.Citation authorityThe current authority. Used only for removal operations. -
isModifiable
private final boolean isModifiabletrue
if the iterator should support theremove()
operation.
-
-
Constructor Details
-
Iter
Iter(Collection<? extends org.opengis.metadata.Identifier> identifiers, boolean isModifiable) Creates a new iterator for the given collection of identifiers.
-
-
Method Details
-
toNext
private void toNext()Advances to the next non-null identifier, skips duplicated authorities, wraps the identifier in an entry if needed and stores the result in thenext
field. If we reach the iteration end, then this method set theidentifiers
iterator tonull
. -
hasNext
public boolean hasNext()If we need to search for the next element, fetches it now. Then returnstrue
if we didn't reached the iteration end. -
next
public Map.Entry<org.opengis.metadata.citation.Citation,String> next() throws NoSuchElementExceptionIf we need to search for the next element, searches it now. Then setnext
tonull
as a flag meaning that next invocations will need to search again for an element, and returns the element that we got.- Specified by:
next
in interfaceIterator<Map.Entry<org.opengis.metadata.citation.Citation,
String>> - Throws:
NoSuchElementException
-
remove
Removes the last element returned bynext()
. Note that if thenext
field is non-null, that would mean that the iteration has moved since the last call to thenext()
method, in which case the iterator is invalid.- Specified by:
remove
in interfaceIterator<Map.Entry<org.opengis.metadata.citation.Citation,
String>> - Throws:
IllegalStateException
-
clone
Iterators are not intended to be cloned. -
toString
Returns the next value to be returned, for debugging purpose only.- Overrides:
toString
in classAbstractMap<org.opengis.metadata.citation.Citation,
Boolean>
-