From d5de1cf2ff4ddc66361acb6aab366b0defed4d7d Mon Sep 17 00:00:00 2001 From: Holt59 Date: Sun, 4 Mar 2018 13:24:40 +0100 Subject: [PATCH] Update acces --- .../org/insa/graph/AccessRestrictions.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/org/insa/graph/AccessRestrictions.java b/src/main/org/insa/graph/AccessRestrictions.java index 89c1f29..8d39f93 100644 --- a/src/main/org/insa/graph/AccessRestrictions.java +++ b/src/main/org/insa/graph/AccessRestrictions.java @@ -48,4 +48,26 @@ public class AccessRestrictions { this.restrictions = restrictions; } + /** + * // TODO: + * + * isRestrictedTo(AccessMode.FOOT, EnumSet.of(Restriction.PRIVATE, + * Restriction.DESTINATION)); + * + * @param mode + * @param restrictions + * @return + */ + public boolean isAllowedForAny(AccessMode mode, EnumSet restrictions) { + AccessRestriction modeRestrictions = this.restrictions.getOrDefault(mode, AccessRestriction.UNKNOWN); + if (modeRestrictions == AccessRestriction.UNKNOWN) { + return true; + } + return restrictions.contains(modeRestrictions); + } + + public boolean isAllowedFor(AccessMode mode, AccessRestriction restrictions) { + return isAllowedForAny(mode, EnumSet.of(restrictions)); + } + }