Package org.insa.graphs.model
Class AccessRestrictions
- java.lang.Object
-
- org.insa.graphs.model.AccessRestrictions
-
public class AccessRestrictions extends java.lang.Object
Class containing access restrictions for roads/arcs.
This class maps transport modes to their restriction and provide interface based on EnumSet to query restrictions.
To each transport is associated at most one restriction per road (no restriction corresponds to
AccessRestrictions.AccessRestriction.UNKNOWN
but a road can have different restrictions for different modes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AccessRestrictions.AccessMode
Enumeration representing the available transport modes.static class
AccessRestrictions.AccessRestriction
Possible restrictions for the roads/arcs.
-
Constructor Summary
Constructors Constructor Description AccessRestrictions()
Create new AccessRestrictions instances with unknown restrictions.AccessRestrictions(java.util.EnumMap<AccessRestrictions.AccessMode,AccessRestrictions.AccessRestriction> restrictions)
Create a new AccessRestrictions instances with the given restrictions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areAllAllowedForAny(java.util.EnumSet<AccessRestrictions.AccessMode> modes, java.util.EnumSet<AccessRestrictions.AccessRestriction> restrictions)
Check if the restriction associated to each given mode is one of the restrictions.AccessRestrictions.AccessRestriction
getRestrictionFor(AccessRestrictions.AccessMode mode)
Retrieve the restriction corresponding to the given mode.boolean
isAllowedFor(AccessRestrictions.AccessMode mode, AccessRestrictions.AccessRestriction restriction)
Check if the restriction for the given mode corresponds to the given restriction.boolean
isAllowedForAny(AccessRestrictions.AccessMode mode, java.util.EnumSet<AccessRestrictions.AccessRestriction> restrictions)
Check if the restriction associated with the given mode is one of the given restrictions.
-
-
-
Constructor Detail
-
AccessRestrictions
public AccessRestrictions()
Create new AccessRestrictions instances with unknown restrictions.
-
AccessRestrictions
public AccessRestrictions(java.util.EnumMap<AccessRestrictions.AccessMode,AccessRestrictions.AccessRestriction> restrictions)
Create a new AccessRestrictions instances with the given restrictions.- Parameters:
restrictions
- Map of restrictions for this instance of AccessRestrictions.
-
-
Method Detail
-
getRestrictionFor
public AccessRestrictions.AccessRestriction getRestrictionFor(AccessRestrictions.AccessMode mode)
Retrieve the restriction corresponding to the given mode.- Parameters:
mode
- Mode for which the restriction should be retrieved.- Returns:
- Restriction for the given mode.
-
isAllowedForAny
public boolean isAllowedForAny(AccessRestrictions.AccessMode mode, java.util.EnumSet<AccessRestrictions.AccessRestriction> restrictions)
Check if the restriction associated with the given mode is one of the given restrictions.- Parameters:
mode
- Mode for which to check the restrictions.restrictions
- List of queried restrictions for the mode.- Returns:
true
if the restriction of the given mode is one of the given restrictions.
-
isAllowedFor
public boolean isAllowedFor(AccessRestrictions.AccessMode mode, AccessRestrictions.AccessRestriction restriction)
Check if the restriction for the given mode corresponds to the given restriction.- Parameters:
mode
- Mode for which the restriction should be checked.restriction
- Restriction to check against.- Returns:
true
if the restriction of the given mode corresponds to the given restriction.
-
areAllAllowedForAny
public boolean areAllAllowedForAny(java.util.EnumSet<AccessRestrictions.AccessMode> modes, java.util.EnumSet<AccessRestrictions.AccessRestriction> restrictions)
Check if the restriction associated to each given mode is one of the restrictions. The restriction may not be the same for all modes.- Parameters:
modes
- Modes for which restrictions should be checked.restrictions
- Set of wanted restrictions for the modes.- Returns:
true
if all the given modes are allowed for any of the given restrictions.
-
-