Package org.goplanit.zoning
Class ConnectoidsImpl<T extends Connectoid>
- java.lang.Object
-
- org.goplanit.utils.wrapper.MapWrapperImpl<Long,V>
-
- org.goplanit.utils.wrapper.LongMapWrapperImpl<E>
-
- org.goplanit.utils.id.ManagedIdEntitiesImpl<T>
-
- org.goplanit.zoning.ConnectoidsImpl<T>
-
- All Implemented Interfaces:
Iterable<T>
,EventListener
,EventListener
,ManagedIdEntities<T>
,LongMapWrapper<T>
,MapWrapper<Long,T>
,Connectoids<T>
,ZoningModifierListener
- Direct Known Subclasses:
DirectedConnectoidsImpl
,UndirectedConnectoidsImpl
public abstract class ConnectoidsImpl<T extends Connectoid> extends ManagedIdEntitiesImpl<T> implements Connectoids<T>
Base implementation of Connectoids container and factory class- Author:
- markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.utils.id.ManagedIdEntitiesImpl
managedIdClass
-
-
Constructor Summary
Constructors Constructor Description ConnectoidsImpl(IdGroupingToken groupId)
ConstructorConnectoidsImpl(ConnectoidsImpl<T> other, boolean deepCopy, BiConsumer<T,T> mapper)
Copy constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Map<Zone,Set<T>>
createIndexByAccessZone()
Lay an index across all connectoids based on their access zones, e.g., a reversed index essentiallyabstract ConnectoidsImpl<T>
deepClone()
Deep clone implementationabstract ConnectoidsImpl
deepCloneWithMapping(BiConsumer<T,T> mapper)
Deep clone implementation where the mapping for its internal copies is captured by the provided mapperEventType[]
getKnownSupportedEventTypes()
Collect explicitly supported event types that are known.void
onZoningModifierEvent(ZoningModificationEvent event)
Support event callbacks whenever zones have been modifiedabstract ConnectoidsImpl<T>
shallowClone()
Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly createdprotected void
updateConnectoidAccessZoneIdReferences()
update the references to all access zones for all connectoids-
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.event.EventListener
hasKnownSupportedEventTypes
-
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
-
ConnectoidsImpl
public ConnectoidsImpl(IdGroupingToken groupId)
Constructor- Parameters:
groupId
- to use for creating ids for instances
-
ConnectoidsImpl
public ConnectoidsImpl(ConnectoidsImpl<T> other, boolean deepCopy, BiConsumer<T,T> mapper)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwisemapper
- to use for tracking mapping between original and copied entity (may be null)
-
-
Method Detail
-
updateConnectoidAccessZoneIdReferences
protected void updateConnectoidAccessZoneIdReferences()
update the references to all access zones for all connectoids
-
getKnownSupportedEventTypes
public EventType[] getKnownSupportedEventTypes()
Collect explicitly supported event types that are known. When not defined the user has to explicitly provide them upon registering the listener on an event producer, otherwise they can be extracted from here- Specified by:
getKnownSupportedEventTypes
in interfaceEventListener
- Returns:
- the supported event types
-
onZoningModifierEvent
public void onZoningModifierEvent(ZoningModificationEvent event)
Support event callbacks whenever zones have been modified- Specified by:
onZoningModifierEvent
in interfaceZoningModifierListener
- Parameters:
event
- representing the zoning modification event at hand
-
createIndexByAccessZone
public Map<Zone,Set<T>> createIndexByAccessZone()
Lay an index across all connectoids based on their access zones, e.g., a reversed index essentially- Specified by:
createIndexByAccessZone
in interfaceConnectoids<T extends Connectoid>
- Returns:
- newly created map of each access zone's its connectoids
-
shallowClone
public abstract ConnectoidsImpl<T> 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 interfaceConnectoids<T extends Connectoid>
- Specified by:
shallowClone
in interfaceManagedIdEntities<T extends Connectoid>
- Specified by:
shallowClone
in interfaceMapWrapper<Long,T extends Connectoid>
- Specified by:
shallowClone
in classManagedIdEntitiesImpl<T extends Connectoid>
- Returns:
- copy
-
deepClone
public abstract ConnectoidsImpl<T> deepClone()
Deep clone implementation- Specified by:
deepClone
in interfaceConnectoids<T extends Connectoid>
- Specified by:
deepClone
in interfaceManagedIdEntities<T extends Connectoid>
- Specified by:
deepClone
in classManagedIdEntitiesImpl<T extends Connectoid>
- Returns:
- deep copy of entities
-
deepCloneWithMapping
public abstract ConnectoidsImpl deepCloneWithMapping(BiConsumer<T,T> mapper)
Deep clone implementation where the mapping for its internal copies is captured by the provided mapper- Specified by:
deepCloneWithMapping
in interfaceConnectoids<T extends Connectoid>
- Specified by:
deepCloneWithMapping
in interfaceManagedIdEntities<T extends Connectoid>
- Specified by:
deepCloneWithMapping
in classManagedIdEntitiesImpl<T extends Connectoid>
- Parameters:
mapper
- to apply to each mapping between original and copy- Returns:
- copy
-
-