Class 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
    • 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 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
    • 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 interface Compatibility<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 add
        direction - LongitudinalDirectionality; permitted direction of movement
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.opentrafficsim.base.HierarchicalType<LaneType>
      • equals

        public boolean equals​(Object obj)
        Overrides:
        equals in class org.opentrafficsim.base.HierarchicalType<LaneType>