Interface Compatibility<U extends HierarchicalType<U,?>,I extends HierarchicalType<I,?>>
- Type Parameters:
U
- infrastructure user typeI
- infrastructure type
- All Known Implementing Classes:
GtuCompatibility
,GtuCompatibleInfraType
,LinkType
public interface Compatibility<U extends HierarchicalType<U,?>,I extends HierarchicalType<I,?>>
Compatibility of infrastructure and users of that infrastructure. Examples are compatibility of a GtuType with a LinkType, or
GtuType with a LaneType, or GtuType with a SensorType. Both infrastructure type and user type are hierarchical, and the
information to make the decision might be higher up in the hierarchy. The outcome depends on whether the infrastructure or
the user hierarchy is traversed first. Example:
Infrastructure: Road, Highway is-a Road User: Vehicle, Car is-a Vehicle, SlowVehicle is-a Vehicle, Bicycle is-a SlowVehicle. Compatibility: (Road, Vehicle) = True, (Highway, SlowVehicle) = FalseSuppose we want to know the compatibility between Bicycle and Highway. The compatibility (Highway, Bicycle) is not defined.
- Infra first: When we examine infrastructure first, we go up the infra hierarchy to Road. (Road, Bicycle) is not given. Now move up Bicycle. (Road, SlowVehicle) is not provided. Move up. (Road, Vehicle) is provided and True. So, Bicycle is allowed on Highway
- user first: we go up the user hierarchy to SlowVehicle. (Highway, SlowVehicle) is defined and False. So, Bicycle is NOT allowed on Highway
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Remove the compatibility cache for this type and all its subtypes.Return the infrastructure for which this compatibility has been defined.boolean
isCompatible
(U userType) Test if a user type is compatible with the infrastructure type.isCompatibleOnInfraLevel
(U userType) Return whether the user type is compatible on this infrastructure level.
-
Method Details
-
isCompatible
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.- Parameters:
userType
- U; the type of the infrastructure user- Returns:
- boolean; true if the user type is compatible with the infrastructure type
-
isCompatibleOnInfraLevel
Return whether the user type is compatible on this infrastructure level.- Parameters:
userType
- 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
-
getInfrastructure
I getInfrastructure()Return the infrastructure for which this compatibility has been defined.- Returns:
- I; the infrastructure for which this compatibility has been defined
-
clearCompatibilityCache
void clearCompatibilityCache()Remove the compatibility cache for this type and all its subtypes.
-