Clean code, remove remaining debug attribute.

This commit is contained in:
Mikael Capelle 2018-03-05 17:55:32 +01:00
parent 7e06e1c4bf
commit 3600752c43
2 changed files with 17 additions and 11 deletions

View File

@ -8,7 +8,14 @@ public class AccessRestrictions {
public enum AccessMode { public enum AccessMode {
// Specific modes // Specific modes
FOOT, BICYCLE, SMALL_MOTORCYCLE, AGRICULTURAL, MOTORCYCLE, MOTORCAR, HEAVY_GOODS, PUBLIC_TRANSPORT; FOOT,
BICYCLE,
SMALL_MOTORCYCLE,
AGRICULTURAL,
MOTORCYCLE,
MOTORCAR,
HEAVY_GOODS,
PUBLIC_TRANSPORT;
// All available modes // All available modes
public static final EnumSet<AccessMode> ALL = EnumSet.allOf(AccessMode.class); public static final EnumSet<AccessMode> ALL = EnumSet.allOf(AccessMode.class);
@ -18,16 +25,17 @@ public class AccessRestrictions {
AccessMode.PUBLIC_TRANSPORT); AccessMode.PUBLIC_TRANSPORT);
// Motor vehicle // Motor vehicle
public static final EnumSet<AccessMode> MOTOR_VEHICLE = EnumSet.range(AccessMode.SMALL_MOTORCYCLE, public static final EnumSet<AccessMode> MOTOR_VEHICLE = EnumSet
AccessMode.PUBLIC_TRANSPORT); .range(AccessMode.SMALL_MOTORCYCLE, AccessMode.PUBLIC_TRANSPORT);
} }
public enum AccessRestriction { public enum AccessRestriction {
ALLOWED, FORBIDDEN, PRIVATE, DESTINATION, DELIVERY, CUSTOMERS, FORESTRY, UNKNOWN; ALLOWED, FORBIDDEN, PRIVATE, DESTINATION, DELIVERY, CUSTOMERS, FORESTRY, UNKNOWN;
// Not private or forbidden // Not private or forbidden
public static final EnumSet<AccessRestriction> ALLOWED_FOR_SOMETHING = EnumSet.of(AccessRestriction.ALLOWED, public static final EnumSet<AccessRestriction> ALLOWED_FOR_SOMETHING = EnumSet.of(
AccessRestriction.DESTINATION, AccessRestriction.DESTINATION, AccessRestriction.DELIVERY, AccessRestriction.ALLOWED, AccessRestriction.DESTINATION,
AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY); AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY);
} }
@ -45,16 +53,13 @@ public class AccessRestrictions {
} }
} }
public long value = 0;
/** /**
* Create a new instance of access restrictions with the given restrictions. * Create a new instance of access restrictions with the given restrictions.
* *
* @param restrictions * @param restrictions
*/ */
public AccessRestrictions(EnumMap<AccessMode, AccessRestriction> restrictions, long value) { public AccessRestrictions(EnumMap<AccessMode, AccessRestriction> restrictions) {
this.restrictions = restrictions; this.restrictions = restrictions;
this.value = value;
} }
/** /**
@ -91,9 +96,10 @@ public class AccessRestrictions {
* @param restrictions * @param restrictions
* *
* @return true if all the given modes are allowed for any of the given * @return true if all the given modes are allowed for any of the given
* restrictions. * restrictions.
*/ */
public boolean areAllAllowedForAny(EnumSet<AccessMode> modes, EnumSet<AccessRestriction> restrictions) { public boolean areAllAllowedForAny(EnumSet<AccessMode> modes,
EnumSet<AccessRestriction> restrictions) {
boolean allowed = true; boolean allowed = true;
for (AccessMode mode: modes) { for (AccessMode mode: modes) {
allowed = allowed && isAllowedForAny(mode, restrictions); allowed = allowed && isAllowedForAny(mode, restrictions);