Class LaneType
- All Implemented Interfaces:
Serializable,Identifiable,Compatibility<GTUType,LaneType>
public class LaneType extends 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-2020 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 classLaneType.DEFAULTSDefault 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
Modifier and Type Method Description voidaddGtuCompatability(GTUType gtuType, LongitudinalDirectionality direction)Add GTU type to compatibility.booleanequals(Object obj)GTUCompatibility<LaneType>getCompatibility()LongitudinalDirectionalitygetDirectionality(GTUType gtuType)Get the permitted driving directions for a given GTU type on this Lane.LongitudinalDirectionalitygetDirectionality(GTUType gtuType, boolean tryParentsOfGTUType)RoadNetworkgetNetwork()inthashCode()LaneTypeinv()Construct a new Lane type based on another Lane type with longitudinally inverted compatibility.BooleanisCompatible(GTUType gtuType, GTUDirectionality direction)Compatibility is solely determined by a specific lane type, and independent of compatibility in super or sub types.booleanisOfType(LaneType.DEFAULTS type)Whether this, or any of the parent types, equals the given type.StringtoString()Methods inherited from class org.opentrafficsim.base.HierarchicalType
commonAncestor, getId, getParent, isOfType
-
Constructor Details
-
LaneType
public LaneType(String id, GTUCompatibility<LaneType> compatibility, RoadNetwork network) throws NullPointerExceptionCreate 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 NullPointerExceptionCreate 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 Details
-
isOfType
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
Construct a new Lane type based on another Lane type with longitudinally inverted compatibility.- Returns:
- LaneType; the new lane type
-
getCompatibility
- Returns:
- the gtu compatibility for this LaneType
-
getNetwork
- Returns:
- the network to which the LinkType belongs
-
isCompatible
Compatibility is solely determined by a specific lane type, and independent of compatibility in super or sub types.- Specified by:
isCompatiblein 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
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
Add GTU type to compatibility.- Parameters:
gtuType- GTUType; the GTU type to adddirection- LongitudinalDirectionality; permitted direction of movement
-
toString
-
hashCode
public int hashCode()- Overrides:
hashCodein classHierarchicalType<LaneType>
-
equals
- Overrides:
equalsin classHierarchicalType<LaneType>
-
getDirectionality
public final LongitudinalDirectionality getDirectionality(GTUType gtuType, boolean tryParentsOfGTUType)- Specified by:
getDirectionalityin interfaceCompatibility<GTUType,LaneType>
-