diff options
Diffstat (limited to 'src/main/java/org/traccar/model')
-rw-r--r-- | src/main/java/org/traccar/model/Permission.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/model/Permission.java b/src/main/java/org/traccar/model/Permission.java index 41dfa43e4..0b2f0584f 100644 --- a/src/main/java/org/traccar/model/Permission.java +++ b/src/main/java/org/traccar/model/Permission.java @@ -54,10 +54,10 @@ public class Permission { this.data = data; var iterator = data.entrySet().iterator(); var owner = iterator.next(); - ownerClass = CLASSES.get(owner.getKey().substring(0, owner.getKey().length() - 2)); + ownerClass = getKeyClass(owner.getKey()); ownerId = owner.getValue(); var property = iterator.next(); - propertyClass = CLASSES.get(property.getKey().substring(0, property.getKey().length() - 2)); + propertyClass = getKeyClass(property.getKey()); propertyId = property.getValue(); } @@ -73,6 +73,10 @@ public class Permission { data.put(getKey(propertyClass), propertyId); } + public static Class<? extends BaseModel> getKeyClass(String key) { + return CLASSES.get(key.substring(0, key.length() - 2)); + } + public static String getKey(Class<?> clazz) { return Introspector.decapitalize(clazz.getSimpleName()) + "Id"; } |