Skip to content

Commit

Permalink
Use pattern variable for casting
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jun 12, 2024
1 parent b373bc3 commit f911362
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public StreetTraversalPermission remove(StreetTraversalPermission perm) {
return get(this.code & ~perm.code);
}

public StreetTraversalPermission modify(boolean permissive, StreetTraversalPermission perm) {
return permissive ? add(perm) : remove(perm);
}

public boolean allows(StreetTraversalPermission perm) {
return (code & perm.code) != 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public boolean canTraverse(TraverseModeSet modes) {
* This checks if start or end vertex is bollard If it is it creates intersection of street edge
* permissions and from/to barriers. Then it checks if mode is allowed to traverse the edge.
* <p>
* By default CAR isn't allowed to traverse barrier but foot and bicycle are. This can be changed
* By default, CAR isn't allowed to traverse barrier but foot and bicycle are. This can be changed
* with different tags
* <p>
* If start/end isn't bollard it just checks the street permissions.
Expand All @@ -179,11 +179,11 @@ public boolean canTraverse(TraverseModeSet modes) {
*/
public boolean canTraverse(TraverseMode mode) {
StreetTraversalPermission permission = getPermission();
if (fromv instanceof BarrierVertex) {
permission = permission.intersection(((BarrierVertex) fromv).getBarrierPermissions());
if (fromv instanceof BarrierVertex bv) {
permission = permission.intersection(bv.getBarrierPermissions());
}
if (tov instanceof BarrierVertex) {
permission = permission.intersection(((BarrierVertex) tov).getBarrierPermissions());
if (tov instanceof BarrierVertex bv) {
permission = permission.intersection(bv.getBarrierPermissions());
}

return permission.allows(mode);
Expand Down

0 comments on commit f911362

Please sign in to comment.