Package org.goplanit.utils.graph
Class ManagedGraphEntitiesImpl<E extends GraphEntity & ManagedId>
- java.lang.Object
-
- org.goplanit.utils.wrapper.MapWrapperImpl<Long,V>
-
- org.goplanit.utils.wrapper.LongMapWrapperImpl<E>
-
- org.goplanit.utils.id.ManagedIdEntitiesImpl<E>
-
- org.goplanit.utils.graph.ManagedGraphEntitiesImpl<E>
-
- Type Parameters:
E
- type of graph entity and managed id entity
- All Implemented Interfaces:
Cloneable
,Iterable<E>
,GraphEntities<E>
,ManagedGraphEntities<E>
,ManagedIdEntities<E>
,LongMapWrapper<E>
,MapWrapper<Long,E>
- Direct Known Subclasses:
CentroidVerticesImpl
,ConjugateConnectoidEdgesImpl
,ConjugateConnectoidNodesImpl
,ConjugateConnectoidSegmentsImpl
,ConjugateLinkSegmentsImpl
,ConjugateLinksImpl
,ConjugateNodesImpl
,ConnectoidEdgesImpl
,ConnectoidSegmentsImpl
,LinksImpl
,MacroscopicLinkSegmentsImpl
,NodesImpl
,ServiceLegSegmentsImpl
,ServiceLegsImpl
,ServiceNodesImpl
public abstract class ManagedGraphEntitiesImpl<E extends GraphEntity & ManagedId> extends ManagedIdEntitiesImpl<E> implements ManagedGraphEntities<E>
Base class for containers of managed id entities that are also graph entities- Author:
- markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.utils.id.ManagedIdEntitiesImpl
managedIdClass
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ManagedGraphEntitiesImpl(Function<E,Long> valueToKey)
Constructor.protected
ManagedGraphEntitiesImpl(Function<E,Long> valueToKey, Class<? extends ManagedId> managedIdClass)
Constructorprotected
ManagedGraphEntitiesImpl(ManagedGraphEntitiesImpl<E> other, boolean deepCopy, BiConsumer<E,E> mapper)
copy constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ManagedGraphEntitiesImpl<E>
deepClone()
Deep clone implementationabstract ManagedGraphEntitiesImpl<E>
deepCloneWithMapping(BiConsumer<E,E> mapper)
Deep clone implementation where the mapping for its internal copies is captured by the provided mapperE
getByXmlId(String xmlId)
Return an entity by its XML idabstract ManagedGraphEntitiesImpl<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.id.ManagedIdEntitiesImpl
getManagedIdClass, recreateIds, reset, updateIdMapping
-
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
get, remove
-
Methods inherited from interface org.goplanit.utils.id.ManagedIdEntities
containsKey, getFactory, getManagedIdClass, groupBy, recreateIds, recreateIds, reset, streamSortedBy
-
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
-
ManagedGraphEntitiesImpl
protected ManagedGraphEntitiesImpl(Function<E,Long> valueToKey, Class<? extends ManagedId> managedIdClass)
Constructor- Parameters:
valueToKey
- the mapping from key to value of the graph entitymanagedIdClass
- should reflect the class signature used for generating the managed id of this class when creating it via the factory of this container
-
ManagedGraphEntitiesImpl
protected ManagedGraphEntitiesImpl(Function<E,Long> valueToKey)
Constructor. while not recommended it is allowed to create managed ids that do not rely on id generation of the class itself. It can be that they rely on child ids or synced ids of other internal referenced classes. In that case this constructor can be used directly. this however should generally be avoided.- Parameters:
valueToKey
- the mapping from key to value of the graph entity
-
ManagedGraphEntitiesImpl
protected ManagedGraphEntitiesImpl(ManagedGraphEntitiesImpl<E> other, boolean deepCopy, BiConsumer<E,E> mapper)
copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwisemapper
- to apply in case of deep copy to each original to copy combination (when provided, may be null)
-
-
Method Detail
-
shallowClone
public abstract ManagedGraphEntitiesImpl<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 & ManagedId>
- Specified by:
shallowClone
in interfaceManagedGraphEntities<E extends GraphEntity & ManagedId>
- Specified by:
shallowClone
in interfaceManagedIdEntities<E extends GraphEntity & ManagedId>
- Specified by:
shallowClone
in interfaceMapWrapper<Long,E extends GraphEntity & ManagedId>
- Specified by:
shallowClone
in classManagedIdEntitiesImpl<E extends GraphEntity & ManagedId>
- Returns:
- copy
-
deepClone
public abstract ManagedGraphEntitiesImpl<E> deepClone()
Deep clone implementation- Specified by:
deepClone
in interfaceGraphEntities<E extends GraphEntity & ManagedId>
- Specified by:
deepClone
in interfaceManagedGraphEntities<E extends GraphEntity & ManagedId>
- Specified by:
deepClone
in interfaceManagedIdEntities<E extends GraphEntity & ManagedId>
- Specified by:
deepClone
in classManagedIdEntitiesImpl<E extends GraphEntity & ManagedId>
- Returns:
- deep copy of entities
-
deepCloneWithMapping
public abstract ManagedGraphEntitiesImpl<E> deepCloneWithMapping(BiConsumer<E,E> mapper)
Deep clone implementation where the mapping for its internal copies is captured by the provided mapper- Specified by:
deepCloneWithMapping
in interfaceGraphEntities<E extends GraphEntity & ManagedId>
- Specified by:
deepCloneWithMapping
in interfaceManagedGraphEntities<E extends GraphEntity & ManagedId>
- Specified by:
deepCloneWithMapping
in interfaceManagedIdEntities<E extends GraphEntity & ManagedId>
- Specified by:
deepCloneWithMapping
in classManagedIdEntitiesImpl<E extends GraphEntity & ManagedId>
- Parameters:
mapper
- to apply to each mapping between original and copy- Returns:
- copy
-
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 & ManagedId>
- Parameters:
xmlId
- the XML id of the entity- Returns:
- the specified entity instance
-
-