Package org.goplanit.utils.graph
Class GraphEntitiesImpl<E extends GraphEntity>
- java.lang.Object
-
- org.goplanit.utils.wrapper.MapWrapperImpl<Long,V>
-
- org.goplanit.utils.wrapper.LongMapWrapperImpl<E>
-
- org.goplanit.utils.graph.GraphEntitiesImpl<E>
-
- Type Parameters:
E
- type of graph entity
- All Implemented Interfaces:
Cloneable
,Iterable<E>
,GraphEntities<E>
,LongMapWrapper<E>
,MapWrapper<Long,E>
- Direct Known Subclasses:
DirectedEdgesImpl
,DirectedVerticesImpl
,EdgeSegmentsImpl
,EdgesImpl
,VerticesImpl
public abstract class GraphEntitiesImpl<E extends GraphEntity> extends LongMapWrapperImpl<E> implements GraphEntities<E>
Base class for containers of entities on graph- Author:
- markr
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GraphEntitiesImpl(Function<E,Long> valueToKey)
Constructorprotected
GraphEntitiesImpl(GraphEntitiesImpl<E> other, boolean deepCopy, BiConsumer<E,E> biConsumer)
copy constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract GraphEntitiesImpl<E>
deepClone()
Deep clone implementationabstract GraphEntitiesImpl<E>
deepCloneWithMapping(BiConsumer<E,E> graphEntityMapper)
Deep clone implementation with mapping retained between original and copies createdE
getByXmlId(String xmlId)
Return an entity by its XML idabstract GraphEntitiesImpl<E>
shallowClone()
Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly created-
Methods inherited from class org.goplanit.utils.wrapper.LongMapWrapperImpl
containsKey, get, remove
-
Methods inherited from class org.goplanit.utils.wrapper.MapWrapperImpl
clear, containsValue, createEmptyInstance, firstMatch, get, getKeyByValue, getMap, getValueToKey, isEmpty, iterator, register, remove, removeIf, setMap, size, toCollection, valuesAsNewSet
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.graph.GraphEntities
forEachMatchingIdIn, getByExternalId, getFactory
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface org.goplanit.utils.wrapper.LongMapWrapper
containsKey, get, remove
-
Methods inherited from interface org.goplanit.utils.wrapper.MapWrapper
addAll, clear, containsValue, firstMatch, forEachIn, get, getFirst, getKeyByValue, isEmpty, register, remove, removeAll, removeIf, size, stream, streamSorted, toCollection, toMap, valuesAsNewSet
-
-
-
-
Constructor Detail
-
GraphEntitiesImpl
protected GraphEntitiesImpl(Function<E,Long> valueToKey)
Constructor- Parameters:
valueToKey
- the mapping from key to value of the graph entity
-
GraphEntitiesImpl
protected GraphEntitiesImpl(GraphEntitiesImpl<E> other, boolean deepCopy, BiConsumer<E,E> biConsumer)
copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwisebiConsumer
- when deepCopy applied to each original and copy, may be null
-
-
Method Detail
-
shallowClone
public abstract GraphEntitiesImpl<E> shallowClone()
Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly created- Specified by:
shallowClone
in interfaceGraphEntities<E extends GraphEntity>
- Specified by:
shallowClone
in interfaceMapWrapper<Long,E extends GraphEntity>
- Specified by:
shallowClone
in classLongMapWrapperImpl<E extends GraphEntity>
- Returns:
- copy
-
deepClone
public abstract GraphEntitiesImpl<E> deepClone()
Deep clone implementation- Specified by:
deepClone
in interfaceGraphEntities<E extends GraphEntity>
- Returns:
- deep copy of entities
-
deepCloneWithMapping
public abstract GraphEntitiesImpl<E> deepCloneWithMapping(BiConsumer<E,E> graphEntityMapper)
Deep clone implementation with mapping retained between original and copies created- Specified by:
deepCloneWithMapping
in interfaceGraphEntities<E extends GraphEntity>
- Parameters:
graphEntityMapper
- that is applied to each deep copy entity mapping pair of origin and copy- Returns:
- pair with deep copy of entities and mapping from original entities to deep copies of these entities
-
getByXmlId
public E getByXmlId(String xmlId)
Return an entity by its XML id Note: not an efficient implementation since it loops over all entities in linear time to identify the correct one, preferably useMapWrapperImpl.get(Object)
instead whenever possible.- Specified by:
getByXmlId
in interfaceGraphEntities<E extends GraphEntity>
- Parameters:
xmlId
- the XML id of the entity- Returns:
- the specified entity instance
-
-