Class GtuCompatibility<T extends HierarchicalType<T,?> & Compatibility<GtuType,T>>
java.lang.Object
org.opentrafficsim.core.compatibility.GtuCompatibility<T>
- Type Parameters:
T
- infrastructure type, e.g. LinkType or LaneType, or water way type
- All Implemented Interfaces:
Compatibility<GtuType,
T>
public class GtuCompatibility<T extends HierarchicalType<T,?> & Compatibility<GtuType,T>>
extends Object
implements Compatibility<GtuType,T>
Compatibility between a GtuType and a certain type of infrastructure. Infrastructure can be any hierarchical structure: a
LinkType, a LaneType, a SensorType, etc.
Copyright (c) 2013-2024 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 Summary
ConstructorDescriptionGtuCompatibility
(GtuCompatibility<T> original) Construct a new Compatibility and deep copy the compatible and forbidden sets from an existing Compatibility.GtuCompatibility
(T infrastructure) Construct a new Compatibility object with empty compatible and forbidden sets. -
Method Summary
Modifier and TypeMethodDescriptionfinal GtuCompatibility<T>
addCompatibleGtuType
(GtuType gtuType) Add an compatible GtuType to this GtuCompatibility.final GtuCompatibility<T>
addIncompatibleGtuType
(GtuType gtuType) Add a incompatible GtuType to this GtuCompatibility.void
Remove the compatibility cache for this type and all its subtypes.boolean
Return the infrastructure for which this compatibility has been defined.int
hashCode()
boolean
isCompatible
(GtuType gtuType) Determine if this Compatibility allows or denies a particular GtuType.isCompatibleOnInfraLevel
(GtuType gtuType) Return whether the user type is compatible on this infrastructure level.final String
toString()
-
Constructor Details
-
GtuCompatibility
Construct a new Compatibility object with empty compatible and forbidden sets.- Parameters:
infrastructure
- I; the infrastructure type, e.g. LinkType, LaneType, SensorType.
-
GtuCompatibility
Construct a new Compatibility and deep copy the compatible and forbidden sets from an existing Compatibility.- Parameters:
original
- GtuCompatibility<I>; the Compatibility from which the compatible and forbidden sets will be copied
-
-
Method Details
-
isCompatible
Determine if this Compatibility allows or denies a particular GtuType.- Specified by:
isCompatible
in interfaceCompatibility<GtuType,
T extends HierarchicalType<T, ?> & Compatibility<GtuType, T>> - Parameters:
gtuType
- GtuType; the GtuType to check- Returns:
- boolean; true if the GtuType is compatible; false if the GtuType is not compatible
-
isCompatibleOnInfraLevel
Return whether the user type is compatible on this infrastructure level.- Specified by:
isCompatibleOnInfraLevel
in interfaceCompatibility<GtuType,
T extends HierarchicalType<T, ?> & Compatibility<GtuType, T>> - Parameters:
gtuType
- U; the type of the infrastructure user- Returns:
- Boolean; 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
-
addCompatibleGtuType
Add an compatible GtuType to this GtuCompatibility.- Parameters:
gtuType
- GtuType; the GtuType to add to the compatible set of this Compatibility- Returns:
- GTUCompatibility<I>; this GtuCompatibility for method call chaining
- Throws:
NullPointerException
- whengtuType
is nullOtsRuntimeException
- when changes are made to compatibility after results have been cached
-
addIncompatibleGtuType
public final GtuCompatibility<T> addIncompatibleGtuType(GtuType gtuType) throws NullPointerException Add a incompatible GtuType to this GtuCompatibility.- Parameters:
gtuType
- GtuType; the GtuType to add to the incompatible set of this Compatibility- Returns:
- GTUCompatibility<I>; this GtuCompatibility for method call chaining
- Throws:
NullPointerException
- whengtuType
is nullOtsRuntimeException
- when changes are made to compatibility after results have been cached
-
getInfrastructure
Return the infrastructure for which this compatibility has been defined.- Specified by:
getInfrastructure
in interfaceCompatibility<GtuType,
T extends HierarchicalType<T, ?> & Compatibility<GtuType, T>> - Returns:
- I; the infrastructure for which this compatibility has been defined
-
clearCompatibilityCache
public void clearCompatibilityCache()Remove the compatibility cache for this type and all its subtypes.- Specified by:
clearCompatibilityCache
in interfaceCompatibility<GtuType,
T extends HierarchicalType<T, ?> & Compatibility<GtuType, T>>
-
hashCode
public int hashCode() -
equals
-
toString
-