Package org.goplanit.utils.id
Class ManagedIdEntitiesImpl<E extends ManagedId>
- java.lang.Object
-
- org.goplanit.utils.wrapper.MapWrapperImpl<Long,V>
-
- org.goplanit.utils.wrapper.LongMapWrapperImpl<E>
-
- org.goplanit.utils.id.ManagedIdEntitiesImpl<E>
-
- Type Parameters:
E- type of managed id entity
- All Implemented Interfaces:
Cloneable,Iterable<E>,ManagedIdEntities<E>,LongMapWrapper<E>,MapWrapper<Long,E>
- Direct Known Subclasses:
ConnectoidEdgesImpl,ConnectoidSegmentsImpl,ConnectoidsImpl,DirectedPathsImpl,LinkSegmentsImpl,LinksImpl,MacroscopicLinkSegmentsImpl,MacroscopicLinkSegmentTypesImpl,ModesImpl,NodesImpl,RoutedModeServicesImpl,RoutedServicesLayersImpl,RoutedTripDeparturesImpl,RoutedTripsImpl,ServiceLegSegmentsImpl,ServiceLegsImpl,ServiceNodesImpl,TransferZoneGroupsImpl,TransportLayersImpl,ZonesImpl
public abstract class ManagedIdEntitiesImpl<E extends ManagedId> extends LongMapWrapperImpl<E> implements ManagedIdEntities<E>
Base class for containers of managed id entities- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<? extends ManagedId>managedIdClassthe class signature used for generating the managed id within the group defined by the token
-
Constructor Summary
Constructors Modifier Constructor Description protectedManagedIdEntitiesImpl(Function<E,Long> valueToKey, Class<? extends ManagedId> managedIdClass)ConstructorprotectedManagedIdEntitiesImpl(ManagedIdEntitiesImpl<E> other)copy constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ManagedIdEntitiesImpl<E>clone()Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly createdClass<? extends ManagedId>getManagedIdClass()Collect the class identifier used for the managed ids within the id group for instances of this class used in this containervoidrecreateIds(boolean resetManagedIdClass)Recreate the ids for all registered entities with or without resettingvoidreset()When reset it called, it not only clears the entries, but also resets the managedids, such that when the container is reused the managed ids start from zero again.protected voidupdateIdMapping()updates the container keys based on currently presiding ids.-
Methods inherited from class org.goplanit.utils.wrapper.LongMapWrapperImpl
containsKey, get, remove
-
Methods inherited from class org.goplanit.utils.wrapper.MapWrapperImpl
clear, contains, createEmptyInstance, findFirst, get, getKeyByValue, getMap, getValueToKey, isEmpty, iterator, register, remove, setMap, size, toCollection, valuesAsNewSet
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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, recreateIds
-
Methods inherited from interface org.goplanit.utils.wrapper.MapWrapper
addAll, clear, contains, findFirst, forEachIn, get, getFirst, getKeyByValue, isEmpty, register, remove, size, toCollection, valuesAsNewSet
-
-
-
-
Constructor Detail
-
ManagedIdEntitiesImpl
protected ManagedIdEntitiesImpl(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
-
ManagedIdEntitiesImpl
protected ManagedIdEntitiesImpl(ManagedIdEntitiesImpl<E> other)
copy constructor- Parameters:
other- to copy
-
-
Method Detail
-
updateIdMapping
protected void updateIdMapping()
updates the container keys based on currently presiding ids. Only to be used when an external force has changed already registered edges' their ids
-
getManagedIdClass
public Class<? extends ManagedId> getManagedIdClass()
Collect the class identifier used for the managed ids within the id group for instances of this class used in this container- Specified by:
getManagedIdClassin interfaceManagedIdEntities<E extends ManagedId>- Returns:
- managedIdClass for instances this factory creates
-
recreateIds
public void recreateIds(boolean resetManagedIdClass)
Recreate the ids for all registered entities with or without resetting- Specified by:
recreateIdsin interfaceManagedIdEntities<E extends ManagedId>- Parameters:
resetManagedIdClass- when true we reset the managedId's counter to zero (via its id class) before recreating the ids, otherwise we simply recreate the managed id by starting with the next available id without resetting
-
reset
public void reset()
When reset it called, it not only clears the entries, but also resets the managedids, such that when the container is reused the managed ids start from zero again. If any entries are managedEntities themselves or contain managed entities themselves, they are reset as well- Specified by:
resetin interfaceManagedIdEntities<E extends ManagedId>
-
clone
public abstract ManagedIdEntitiesImpl<E> clone()
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:
clonein interfaceManagedIdEntities<E extends ManagedId>- Specified by:
clonein interfaceMapWrapper<Long,E extends ManagedId>- Specified by:
clonein classLongMapWrapperImpl<E extends ManagedId>- Returns:
- copy
-
-