Class GtuCompatibleInfraType<T extends GtuCompatibleInfraType<T,I>,I extends HierarchicallyTyped<T,I>>

java.lang.Object
org.opentrafficsim.base.HierarchicalType<T,I>
org.opentrafficsim.core.compatibility.GtuCompatibleInfraType<T,I>
Type Parameters:
T - The infrastructure type
I - Infrastructure type belonging to hierarchical type
All Implemented Interfaces:
Identifiable, Type<T>, Compatibility<GtuType,T>
Direct Known Subclasses:
DetectorType, LinkType

public abstract class GtuCompatibleInfraType<T extends GtuCompatibleInfraType<T,I>,I extends HierarchicallyTyped<T,I>> extends HierarchicalType<T,I> implements Compatibility<GtuType,T>
GtuCompatibleInfraType is a HierarchicalType that implements the delegation methods for GTU compatibility.

Copyright (c) 2022-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Constructor Details

    • GtuCompatibleInfraType

      public GtuCompatibleInfraType(String id, T parent)
      Instantiate an infrastructure type.
      Parameters:
      id - the id
      parent - the parent
    • GtuCompatibleInfraType

      public GtuCompatibleInfraType(String id)
      Instantiate an infrastructure type without a parent.
      Parameters:
      id - the id
  • Method Details

    • addCompatibleGtuType

      public final GtuCompatibility<T> addCompatibleGtuType(GtuType gtuType)
      Add an compatible GtuType to this GtuCompatibility.
      Parameters:
      gtuType - the GtuType to add to the compatible set of this Compatibility
      Returns:
      this GtuCompatibility for method call chaining
      Throws:
      NullPointerException - when gtuType is null
      OtsRuntimeException - when changes are made to compatibility after results have been cached
    • addIncompatibleGtuType

      public final GtuCompatibility<T> addIncompatibleGtuType(GtuType gtuType)
      Add a incompatible GtuType to this GtuCompatibility.
      Parameters:
      gtuType - the GtuType to add to the incompatible set of this Compatibility
      Returns:
      this GtuCompatibility for method call chaining
      Throws:
      NullPointerException - when gtuType is null
      OtsRuntimeException - when changes are made to compatibility after results have been cached
    • isCompatible

      public boolean isCompatible(GtuType gtuType)
      Description copied from interface: Compatibility
      Test if a user type is compatible with the infrastructure type. Examples are compatibility of a GtuType with a LinkType, or GtuType with a LaneType, or GtuType with a SensorType. Since both GtuType and InfrastructureType are hierarchical types, it might be that compatibility has to look one or more levels up to determine whether user type and infrastructure type are compatible. The outcome depends on which hierarchy is examined first. The way this is implemented is as follows: First, all combinations in the two hierarchies will be searched for explicitly forbidden combinations. If there is a forbidden combination, compatibility is false. If the compatibility is not explicitly false, the hierarchies will be checked to look for an explicit compatibility that is true. If there is any, the result is true. If nothing is specified in the hierarchies (neither true nor false), the compatibility is false.
      Specified by:
      isCompatible in interface Compatibility<T extends GtuCompatibleInfraType<T,I>,I extends HierarchicallyTyped<T,I>>
      Parameters:
      gtuType - the type of the infrastructure user
      Returns:
      true if the user type is compatible with the infrastructure type
    • isCompatibleOnInfraLevel

      public Boolean isCompatibleOnInfraLevel(GtuType gtuType)
      Description copied from interface: Compatibility
      Return whether the user type is compatible on this infrastructure level.
      Specified by:
      isCompatibleOnInfraLevel in interface Compatibility<T extends GtuCompatibleInfraType<T,I>,I extends HierarchicallyTyped<T,I>>
      Parameters:
      gtuType - the type of the infrastructure user
      Returns:
      true if explicitly defined to be compatible on this level; false if explicitly defined to be incompatible on this level; null if not defined on this level
    • getInfrastructure

      public T getInfrastructure()
      Description copied from interface: Compatibility
      Return the infrastructure for which this compatibility has been defined.
      Specified by:
      getInfrastructure in interface Compatibility<T extends GtuCompatibleInfraType<T,I>,I extends HierarchicallyTyped<T,I>>
      Returns:
      the infrastructure for which this compatibility has been defined
    • clearCompatibilityCache

      public void clearCompatibilityCache()
      Description copied from interface: Compatibility
      Remove the compatibility cache for this type and all its subtypes.
      Specified by:
      clearCompatibilityCache in interface Compatibility<T extends GtuCompatibleInfraType<T,I>,I extends HierarchicallyTyped<T,I>>
    • getGtuCompatibility

      public GtuCompatibility<T> getGtuCompatibility()
      Return the GTU compatibility of this infra type.
      Returns:
      the GTU compatibility of this infra type