Package org.planit.zoning
Class ConnectoidImpl
- java.lang.Object
-
- org.planit.utils.id.ExternalIdAbleImpl
-
- org.planit.zoning.ConnectoidImpl
-
- All Implemented Interfaces:
Comparable<Idable>
,Iterable<Zone>
,ExternalIdable
,Idable
,Connectoid
- Direct Known Subclasses:
DirectedConnectoidImpl
,UndirectedConnectoidImpl
public abstract class ConnectoidImpl extends ExternalIdAbleImpl implements Connectoid
connectoid connecting one or more (transfer/OD) zone(s) to the physical road network, the type of connectoid depends on the implementing class- Author:
- markr
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ConnectoidImpl.AccessZoneProperties
Stores access properties for each zone
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<Long,ConnectoidImpl.AccessZoneProperties>
accessZones
the zones and their properties accessible from this connectoidprotected String
name
name of the connectoid if anyprotected ConnectoidType
type
the type of connectoid to identify its purpose more easily-
Fields inherited from interface org.planit.utils.zoning.Connectoid
DEFAULT_CONNECTOID_TYPE, DEFAULT_LENGTH_KM
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConnectoidImpl(IdGroupingToken idToken)
Constructorprotected
ConnectoidImpl(IdGroupingToken idToken, Zone accessZone, double length)
Constructorprotected
ConnectoidImpl(ConnectoidImpl connectoidImpl)
Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Zone
addAccessZone(Zone accessZone)
add an access zone with default propertiesvoid
addAllowedMode(Zone accessZone, Mode... allowedModes)
add an allowed mode to the alreadyprotected static long
generateConnectoidId(IdGroupingToken groupId)
Generate connectoid idCollection<Zone>
getAccessZones()
the zones that can be accessed by this connectoidZone
getFirstAccessZone()
first available zone that is accessible based on the first entry the iterator returnsDouble
getLength(Zone accessZone)
length can be used to virtually assign a length to the connectoid/zone combinationString
getName()
The name of the connectoidlong
getNumberOfAccessZones()
the number of accessible zones registeredConnectoidType
getType()
The type of the connectoidboolean
hasAccessZone(Zone accessZone)
check if zone is registered as access zoneboolean
isModeAllowed(Zone accessZone, Mode mode)
Verify if a mode is allowed access to the zone via this connectoidIterator<Zone>
iterator()
void
setLength(Zone accessZone, double length)
add an access zone and provide length to this connectoidvoid
setName(String name)
Set the name of the connectoidvoid
setType(ConnectoidType type)
Set the type of the connectoid-
Methods inherited from class org.planit.utils.id.ExternalIdAbleImpl
getExternalId, getId, getXmlId, setExternalId, setId, setXmlId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.id.ExternalIdable
getExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
name
protected String name
name of the connectoid if any
-
type
protected ConnectoidType type
the type of connectoid to identify its purpose more easily
-
accessZones
protected final HashMap<Long,ConnectoidImpl.AccessZoneProperties> accessZones
the zones and their properties accessible from this connectoid
-
-
Constructor Detail
-
ConnectoidImpl
protected ConnectoidImpl(IdGroupingToken idToken)
Constructor- Parameters:
idToken
- contiguous id generation within this group for instances of this class
-
ConnectoidImpl
protected ConnectoidImpl(ConnectoidImpl connectoidImpl)
Copy constructor- Parameters:
connectoidImpl
- to copy
-
ConnectoidImpl
protected ConnectoidImpl(IdGroupingToken idToken, Zone accessZone, double length)
Constructor- Parameters:
idToken
- contiguous id generation within this group for instances of this classaccessZone
- for the connectoidlength
- for the connection
-
-
Method Detail
-
generateConnectoidId
protected static long generateConnectoidId(IdGroupingToken groupId)
Generate connectoid id- Parameters:
groupId
- contiguous id generation within this group for instances of this class- Returns:
- id of connectoid
-
setType
public void setType(ConnectoidType type)
Set the type of the connectoid- Specified by:
setType
in interfaceConnectoid
- Parameters:
type
- its type
-
getType
public ConnectoidType getType()
The type of the connectoid- Specified by:
getType
in interfaceConnectoid
- Returns:
- its type
-
setName
public void setName(String name)
Set the name of the connectoid- Specified by:
setName
in interfaceConnectoid
- Parameters:
name
- its name
-
getName
public String getName()
The name of the connectoid- Specified by:
getName
in interfaceConnectoid
- Returns:
- its name
-
getAccessZones
public Collection<Zone> getAccessZones()
the zones that can be accessed by this connectoid- Specified by:
getAccessZones
in interfaceConnectoid
- Returns:
- accessible zones
-
getFirstAccessZone
public Zone getFirstAccessZone()
first available zone that is accessible based on the first entry the iterator returns- Specified by:
getFirstAccessZone
in interfaceConnectoid
- Returns:
- first available zone
-
getNumberOfAccessZones
public long getNumberOfAccessZones()
the number of accessible zones registered- Specified by:
getNumberOfAccessZones
in interfaceConnectoid
- Returns:
- number of accessible zones
-
getLength
public Double getLength(Zone accessZone)
length can be used to virtually assign a length to the connectoid/zone combination- Specified by:
getLength
in interfaceConnectoid
- Parameters:
accessZone
- to collect length for- Returns:
- length (null if zone is not registered)
-
addAccessZone
public Zone addAccessZone(Zone accessZone)
add an access zone with default properties- Specified by:
addAccessZone
in interfaceConnectoid
- Parameters:
accessZone
- to register as accessible- Returns:
- overwritten zone if any
-
isModeAllowed
public boolean isModeAllowed(Zone accessZone, Mode mode) throws PlanItException
Verify if a mode is allowed access to the zone via this connectoid- Specified by:
isModeAllowed
in interfaceConnectoid
- Parameters:
accessZone
- to verifymode
- to verify if allowed- Returns:
- true when allowed, false otherwise
- Throws:
PlanItException
- thrown if provided zone is not valid
-
hasAccessZone
public boolean hasAccessZone(Zone accessZone)
check if zone is registered as access zone- Specified by:
hasAccessZone
in interfaceConnectoid
- Parameters:
accessZone
- to verify- Returns:
- true when registered, false otherwise
-
setLength
public void setLength(Zone accessZone, double length)
add an access zone and provide length to this connectoid- Specified by:
setLength
in interfaceConnectoid
- Parameters:
accessZone
- to set length forlength
- to traverse between connectoid and zone
-
addAllowedMode
public void addAllowedMode(Zone accessZone, Mode... allowedModes)
add an allowed mode to the already- Specified by:
addAllowedMode
in interfaceConnectoid
- Parameters:
accessZone
- to add allowed mode(s) toallowedModes
- to add
-
-