Package org.goplanit.zoning
Class TransferZoneGroupImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.zoning.TransferZoneGroupImpl
-
- All Implemented Interfaces:
Cloneable,Comparable<IdAble>,Iterable<TransferZone>,ExternalIdAble,IdAble,ManagedId,TransferZoneGroup
public class TransferZoneGroupImpl extends ExternalIdAbleImpl implements TransferZoneGroup
A transfer zone group implementation. Practically this can be used to represent public transport stations for example- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringnamename of the transfer zone groupprotected Map<Long,TransferZone>transferZoneMapMap storing all the transfer zones in the group-
Fields inherited from interface org.goplanit.utils.zoning.TransferZoneGroup
TRANSFER_ZONE_GROUP_ID_CLASS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTransferZoneGroupImpl(IdGroupingToken tokenId)ConstructorTransferZoneGroupImpl(TransferZoneGroupImpl transferZoneGroupImpl)Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TransferZoneaddTransferZone(TransferZone transferZone)Add a transferZone and also register this group on this transfer zone at the same timeTransferZoneGroupImplclone()Create a shallow copy of this entityprotected static longgenerateTransferZoneGroupId(IdGroupingToken tokenId)generate unique transfer zone group idStringgetName()Name of the groupCollection<TransferZone>getTransferZones()create a view of the registered transfer zones.booleanhasTransferZone(TransferZone transferZone)Verify if transfer zone is presentIterator<TransferZone>iterator()longrecreateManagedIds(IdGroupingToken tokenId)recreate the internal id(s) and set them including the Idable idprotected voidrecreateTransferZoneIdMapping()recreate the mapping such that all the keys used for each transfer zone reflect their internal id.TransferZoneremoveTransferZone(TransferZone transferZone)remove a transfer zone from the group, and also remove the reference on the transfer zone at the same timevoidsetName(String name)set Name of the groupintsize()Number of registered transfer zones-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
getExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
resetChildManagedIdEntities
-
Methods inherited from interface org.goplanit.utils.zoning.TransferZoneGroup
getFirst, getIdClass, hasName, hasTransferZones, isEmpty
-
-
-
-
Field Detail
-
transferZoneMap
protected Map<Long,TransferZone> transferZoneMap
Map storing all the transfer zones in the group
-
name
protected String name
name of the transfer zone group
-
-
Constructor Detail
-
TransferZoneGroupImpl
protected TransferZoneGroupImpl(IdGroupingToken tokenId)
Constructor- Parameters:
tokenId- to use
-
TransferZoneGroupImpl
public TransferZoneGroupImpl(TransferZoneGroupImpl transferZoneGroupImpl)
Copy constructor- Parameters:
transferZoneGroupImpl- to copy
-
-
Method Detail
-
recreateTransferZoneIdMapping
protected void recreateTransferZoneIdMapping()
recreate the mapping such that all the keys used for each transfer zone reflect their internal id. To be called whenever the ids of transfer zones are changed
-
generateTransferZoneGroupId
protected static long generateTransferZoneGroupId(IdGroupingToken tokenId)
generate unique transfer zone group id- Parameters:
tokenId- contiguous id generation within this group for instances of this class- Returns:
- odZoneId
-
iterator
public Iterator<TransferZone> iterator()
- Specified by:
iteratorin interfaceIterable<TransferZone>
-
getName
public String getName()
Name of the group- Specified by:
getNamein interfaceTransferZoneGroup- Returns:
- name
-
setName
public void setName(String name)
set Name of the group- Specified by:
setNamein interfaceTransferZoneGroup- Parameters:
name- to set
-
addTransferZone
public TransferZone addTransferZone(TransferZone transferZone)
Add a transferZone and also register this group on this transfer zone at the same time- Specified by:
addTransferZonein interfaceTransferZoneGroup- Parameters:
transferZone- to add- Returns:
- previousTransferZone under same id (if any)
-
removeTransferZone
public TransferZone removeTransferZone(TransferZone transferZone)
remove a transfer zone from the group, and also remove the reference on the transfer zone at the same time- Specified by:
removeTransferZonein interfaceTransferZoneGroup- Parameters:
transferZone- to remove- Returns:
- removed transfer zone
-
hasTransferZone
public boolean hasTransferZone(TransferZone transferZone)
Verify if transfer zone is present- Specified by:
hasTransferZonein interfaceTransferZoneGroup- Parameters:
transferZone- to check- Returns:
- true when present, false otherwise
-
size
public int size()
Number of registered transfer zones- Specified by:
sizein interfaceTransferZoneGroup- Returns:
- number of registered transfer zones
-
getTransferZones
public Collection<TransferZone> getTransferZones()
create a view of the registered transfer zones. Any changes are reflected in the group as well- Specified by:
getTransferZonesin interfaceTransferZoneGroup- Returns:
- registered transfer zones
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIdsin interfaceManagedId- Parameters:
tokenId- to use- Returns:
- the updated internal id
-
clone
public TransferZoneGroupImpl clone()
Create a shallow copy of this entity- Specified by:
clonein interfaceIdAble- Specified by:
clonein interfaceTransferZoneGroup- Overrides:
clonein classExternalIdAbleImpl- Returns:
- shallow copy of entity
-
-