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:
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 String
name
name of the transfer zone groupprotected Map<Long,TransferZone>
transferZoneMap
Map 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 protected
TransferZoneGroupImpl(IdGroupingToken tokenId)
ConstructorTransferZoneGroupImpl(TransferZoneGroupImpl other, boolean deepCopy)
Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TransferZone
addTransferZone(TransferZone transferZone)
Add a transferZone and also register this group on this transfer zone at the same timeTransferZoneGroupImpl
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.protected static long
generateTransferZoneGroupId(IdGroupingToken tokenId)
generate unique transfer zone group idString
getName()
Name of the groupCollection<TransferZone>
getTransferZones()
create a view of the registered transfer zones.boolean
hasTransferZone(TransferZone transferZone)
Verify if transfer zone is presentIterator<TransferZone>
iterator()
long
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idprotected void
recreateTransferZoneIdMapping()
recreate the mapping such that all the keys used for each transfer zone reflect their internal id.TransferZone
removeTransferZone(TransferZone transferZone)
remove a transfer zone from the group, and also remove the reference on the transfer zone at the same timevoid
setName(String name)
set Name of the groupTransferZoneGroupImpl
shallowClone()
Create a shallow copy of this entityint
size()
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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, 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
addAllTransferZones, 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 other, boolean deepCopy)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
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:
iterator
in interfaceIterable<TransferZone>
-
getName
public String getName()
Name of the group- Specified by:
getName
in interfaceTransferZoneGroup
- Returns:
- name
-
setName
public void setName(String name)
set Name of the group- Specified by:
setName
in 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:
addTransferZone
in 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:
removeTransferZone
in interfaceTransferZoneGroup
- Parameters:
transferZone
- to remove- Returns:
- removed transfer zone
-
hasTransferZone
public boolean hasTransferZone(TransferZone transferZone)
Verify if transfer zone is present- Specified by:
hasTransferZone
in interfaceTransferZoneGroup
- Parameters:
transferZone
- to check- Returns:
- true when present, false otherwise
-
size
public int size()
Number of registered transfer zones- Specified by:
size
in 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:
getTransferZones
in 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:
recreateManagedIds
in interfaceManagedId
- Parameters:
tokenId
- to use (may be null in case managed id entity does not rely on token to recreate its managed id(s))- Returns:
- the updated internal id
-
shallowClone
public TransferZoneGroupImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceTransferZoneGroup
- Overrides:
shallowClone
in classExternalIdAbleImpl
- Returns:
- shallow copy of entity
-
deepClone
public TransferZoneGroupImpl deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceTransferZoneGroup
- Overrides:
deepClone
in classExternalIdAbleImpl
- Returns:
- deep copy of entity
-
-