Package org.goplanit.utils.graph
Interface GraphEntities<E extends GraphEntity>
-
- Type Parameters:
E
- type of graph entity
- All Superinterfaces:
Cloneable
,Iterable<E>
,LongMapWrapper<E>
,MapWrapper<Long,E>
- All Known Subinterfaces:
CentroidVertices
,ConjugateConnectoidEdges
,ConjugateConnectoidNodes
,ConjugateConnectoidSegments
,ConjugateDirectedEdges
,ConjugateDirectedVertices
,ConjugateEdges
,ConjugateEdgeSegments
,ConjugateLinks
,ConjugateLinkSegments
,ConjugateNodes
,ConjugateVertices
,ConnectoidEdges
,ConnectoidSegments
,DirectedEdges
,DirectedVertices
,Edges
,EdgeSegments
,Links<L>
,LinkSegments
,MacroscopicLinks
,MacroscopicLinkSegments
,ManagedGraphEntities<E>
,Nodes
,ServiceLegs
,ServiceLegSegments
,ServiceNodes
,Vertices
- All Known Implementing Classes:
CentroidVerticesImpl
,ConjugateConnectoidEdgesImpl
,ConjugateConnectoidNodesImpl
,ConjugateConnectoidSegmentsImpl
,ConjugateLinkSegmentsImpl
,ConjugateLinksImpl
,ConjugateNodesImpl
,ConnectoidEdgesImpl
,ConnectoidSegmentsImpl
,DirectedEdgesImpl
,DirectedVerticesImpl
,EdgeSegmentsImpl
,EdgesImpl
,GraphEntitiesImpl
,LinksImpl
,MacroscopicLinkSegmentsImpl
,MacroscopicLinksImpl
,ManagedGraphEntitiesImpl
,NodesImpl
,ServiceLegSegmentsImpl
,ServiceLegsImpl
,ServiceNodesImpl
,VerticesImpl
public interface GraphEntities<E extends GraphEntity> extends LongMapWrapper<E>, Cloneable
Container class for any graph entities and a factory to create them- Author:
- markr
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description GraphEntities<E>
deepClone()
Deep clone implementationGraphEntities<E>
deepCloneWithMapping(BiConsumer<E,E> graphEntityMapper)
Deep clone implementation with mapping retained between original and copies createddefault <T extends IdAble>
voidforEachMatchingIdIn(Iterable<T> values, Consumer<T> consumer)
Apply provided consumer to each element in values as long as that element is registered under the same id.default Collection<E>
getByExternalId(String externalId)
Collect all entities based on a matching external id.E
getByXmlId(String xmlId)
Return an entity by its XML idstatic <EE extends GraphEntity>
EEgetByXmlId(GraphEntities<EE> container, String xmlId)
find by XML id Note: not an efficient implementation since it loops over all entities in linear time to identify the correct one, preferably useMapWrapper.get(Object)
instead whenever possible.GraphEntityFactory<E>
getFactory()
Factory to create instance of graph entity (for this container class)GraphEntities<E>
shallowClone()
shallow clone implementation-
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
-
-
-
-
Method Detail
-
getByXmlId
static <EE extends GraphEntity> EE getByXmlId(GraphEntities<EE> container, String xmlId)
find by XML id Note: not an efficient implementation since it loops over all entities in linear time to identify the correct one, preferably useMapWrapper.get(Object)
instead whenever possible.- Type Parameters:
EE
- entity type- Parameters:
container
- the container to apply toxmlId
- to find match for- Returns:
- found match, null if none found
-
getFactory
GraphEntityFactory<E> getFactory()
Factory to create instance of graph entity (for this container class)- Returns:
- entity factory
-
shallowClone
GraphEntities<E> shallowClone()
shallow clone implementation- Specified by:
shallowClone
in interfaceMapWrapper<Long,E extends GraphEntity>
- Returns:
- clone of entities
-
deepClone
GraphEntities<E> deepClone()
Deep clone implementation- Returns:
- deep copy of entities
-
deepCloneWithMapping
GraphEntities<E> deepCloneWithMapping(BiConsumer<E,E> graphEntityMapper)
Deep clone implementation with mapping retained between original and copies created- 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
E getByXmlId(String xmlId)
Return an entity by its XML id- Parameters:
xmlId
- the XML id of the entity- Returns:
- the specified entity instance
-
getByExternalId
default Collection<E> getByExternalId(String externalId)
Collect all entities based on a matching external id. Entities are not indexed by external id so this is a very inefficient linear search through all registered entities.- Parameters:
externalId
- to match- Returns:
- found matching links
-
forEachMatchingIdIn
default <T extends IdAble> void forEachMatchingIdIn(Iterable<T> values, Consumer<T> consumer)
Apply provided consumer to each element in values as long as that element is registered under the same id.- Type Parameters:
T
- values type- Parameters:
values
- to apply consumer to when they are registered in this wrapperconsumer
- to apply
-
-