Class LaneType
- java.lang.Object
-
- org.opentrafficsim.base.Type<T>
-
- org.opentrafficsim.base.HierarchicalType<LaneType>
-
- org.opentrafficsim.road.network.lane.LaneType
-
- All Implemented Interfaces:
Serializable
,org.opentrafficsim.base.Identifiable
,Compatibility<GTUType,LaneType>
public class LaneType extends org.opentrafficsim.base.HierarchicalType<LaneType> implements Serializable, Compatibility<GTUType,LaneType>
Lane type to indicate compatibility with GTU types. The id of a LaneType should be unique. This is, however, not checked or enforced, as the LaneType is not a singleton as the result of the compatibilitySet. Different simulations running in the same GTU can have different compatibilitySets for LaneTypes with the same id. Therefore, uniqueness is not enforced.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate: 2015-08-30 00:16:51 +0200 (Sun, 30 Aug 2015) $, @version $Revision: 1329 $, by $Author: averbraeck $, initial version Aug 21, 2014
- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LaneType.DEFAULTS
Default types with their name.
-
Constructor Summary
Constructors Constructor Description LaneType(String id, GTUCompatibility<LaneType> compatibility, RoadNetwork network)
Create a new Lane type with a compatibility set.LaneType(String id, LaneType parent, GTUCompatibility<LaneType> compatibility, RoadNetwork network)
Create a new Lane type with a compatibility set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGtuCompatability(GTUType gtuType, LongitudinalDirectionality direction)
Add GTU type to compatibility.boolean
equals(Object obj)
GTUCompatibility<LaneType>
getCompatibility()
LongitudinalDirectionality
getDirectionality(GTUType gtuType)
Get the permitted driving directions for a given GTU type on this Lane.LongitudinalDirectionality
getDirectionality(GTUType gtuType, boolean tryParentsOfGTUType)
RoadNetwork
getNetwork()
int
hashCode()
LaneType
inv()
Construct a new Lane type based on another Lane type with longitudinally inverted compatibility.Boolean
isCompatible(GTUType gtuType, GTUDirectionality direction)
Compatibility is solely determined by a specific lane type, and independent of compatibility in super or sub types.boolean
isOfType(LaneType.DEFAULTS type)
Whether this, or any of the parent types, equals the given type.String
toString()
-
-
-
Constructor Detail
-
LaneType
public LaneType(String id, GTUCompatibility<LaneType> compatibility, RoadNetwork network) throws NullPointerException
Create a new Lane type with a compatibility set.- Parameters:
id
- String; the id of the lane type.compatibility
- GTUCompatibility<LaneType>; the collection of compatible GTUTypes for this LaneType. Compatibility is solely determined by a specific lane type, and independent of compatibility in super or sub types.network
- RoadNetwork; The network to which the LaneType belongs- Throws:
NullPointerException
- if either the id is null, or the compatibilitySet is null
-
LaneType
public LaneType(String id, LaneType parent, GTUCompatibility<LaneType> compatibility, RoadNetwork network) throws NullPointerException
Create a new Lane type with a compatibility set.- Parameters:
id
- String; the id of the lane type.parent
- LaneType; parent typecompatibility
- GTUCompatibility<LaneType>; the collection of compatible GTUTypes for this LaneType. Compatibility is solely determined by a specific lane type, and independent of compatibility in super or sub types.network
- RoadNetwork; The network to which the LaneType belongs- Throws:
NullPointerException
- if either the id is null, or the compatibilitySet is null
-
-
Method Detail
-
isOfType
public boolean isOfType(LaneType.DEFAULTS type)
Whether this, or any of the parent types, equals the given type.- Parameters:
type
- DEFAULTS; type- Returns:
- whether this, or any of the parent types, equals the given type
-
inv
public final LaneType inv()
Construct a new Lane type based on another Lane type with longitudinally inverted compatibility.- Returns:
- LaneType; the new lane type
-
getCompatibility
public GTUCompatibility<LaneType> getCompatibility()
- Returns:
- the gtu compatibility for this LaneType
-
getNetwork
public RoadNetwork getNetwork()
- Returns:
- the network to which the LinkType belongs
-
isCompatible
public final Boolean isCompatible(GTUType gtuType, GTUDirectionality direction)
Compatibility is solely determined by a specific lane type, and independent of compatibility in super or sub types.- Specified by:
isCompatible
in interfaceCompatibility<GTUType,LaneType>
- Parameters:
gtuType
- GTUType; GTU type to look for compatibility.direction
- GTUDirectionality; the direction that the GTU is moving (with respect to the direction of the design line of the Link)- Returns:
- boolean; true if this LaneType permits GTU type in the given direction
-
getDirectionality
public final LongitudinalDirectionality getDirectionality(GTUType gtuType)
Get the permitted driving directions for a given GTU type on this Lane.- Parameters:
gtuType
- GTUType; the GTU type- Returns:
- LongitudinalDirectionality; the permitted directions of the GTU type on this Lane
-
addGtuCompatability
public final void addGtuCompatability(GTUType gtuType, LongitudinalDirectionality direction)
Add GTU type to compatibility.- Parameters:
gtuType
- GTUType; the GTU type to adddirection
- LongitudinalDirectionality; permitted direction of movement
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classorg.opentrafficsim.base.HierarchicalType<LaneType>
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classorg.opentrafficsim.base.HierarchicalType<LaneType>
-
getDirectionality
public final LongitudinalDirectionality getDirectionality(GTUType gtuType, boolean tryParentsOfGTUType)
- Specified by:
getDirectionality
in interfaceCompatibility<GTUType,LaneType>
-
-