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 typeI- 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 Summary
ConstructorsConstructorDescriptionInstantiate an infrastructure type without a parent.GtuCompatibleInfraType(String id, T parent) Instantiate an infrastructure type. -
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.voidRemove the compatibility cache for this type and all its subtypes.Return the GTU compatibility of this infra type.Return the infrastructure for which this compatibility has been defined.booleanisCompatible(GtuType gtuType) Test if a user type is compatible with the infrastructure type.isCompatibleOnInfraLevel(GtuType gtuType) Return whether the user type is compatible on this infrastructure level.Methods inherited from class org.opentrafficsim.base.HierarchicalType
commonAncestor, equals, getChildren, getId, getParent, hashCode, isOfType
-
Constructor Details
-
GtuCompatibleInfraType
Instantiate an infrastructure type.- Parameters:
id- the idparent- the parent
-
GtuCompatibleInfraType
Instantiate an infrastructure type without a parent.- Parameters:
id- the id
-
-
Method Details
-
addCompatibleGtuType
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- whengtuTypeis nullOtsRuntimeException- when changes are made to compatibility after results have been cached
-
addIncompatibleGtuType
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- whengtuTypeis nullOtsRuntimeException- when changes are made to compatibility after results have been cached
-
isCompatible
Description copied from interface:CompatibilityTest 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:
isCompatiblein interfaceCompatibility<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
Description copied from interface:CompatibilityReturn whether the user type is compatible on this infrastructure level.- Specified by:
isCompatibleOnInfraLevelin interfaceCompatibility<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
Description copied from interface:CompatibilityReturn the infrastructure for which this compatibility has been defined.- Specified by:
getInfrastructurein interfaceCompatibility<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:CompatibilityRemove the compatibility cache for this type and all its subtypes.- Specified by:
clearCompatibilityCachein interfaceCompatibility<T extends GtuCompatibleInfraType<T,I>, I extends HierarchicallyTyped<T, I>>
-
getGtuCompatibility
Return the GTU compatibility of this infra type.- Returns:
- the GTU compatibility of this infra type
-