aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-27 16:46:52 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-27 16:46:52 +0500
commit5446776933ff412361a3c7812c2bb6de9a78ccaf (patch)
tree965af40404eba36cef53a12f166d7e3a601408e3 /src/org/traccar
parente8a758072e9368f6977880e1aa607351d7cf619a (diff)
downloadtraccar-server-5446776933ff412361a3c7812c2bb6de9a78ccaf.tar.gz
traccar-server-5446776933ff412361a3c7812c2bb6de9a78ccaf.tar.bz2
traccar-server-5446776933ff412361a3c7812c2bb6de9a78ccaf.zip
Optimize a few IFs
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/Context.java2
-rw-r--r--src/org/traccar/api/BaseObjectResource.java13
2 files changed, 6 insertions, 9 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index 75a7d179b..306a37e83 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -378,7 +378,7 @@ public final class Context {
identityManager = testIdentityManager;
}
- public static <T extends BaseModel> BaseObjectManager<T> getManager(Class<? extends BaseModel> clazz) {
+ public static <T extends BaseModel> BaseObjectManager<T> getManager(Class<T> clazz) {
if (clazz.equals(Device.class)) {
return (BaseObjectManager<T>) deviceManager;
} else if (clazz.equals(Group.class)) {
diff --git a/src/org/traccar/api/BaseObjectResource.java b/src/org/traccar/api/BaseObjectResource.java
index 11e9a5d01..ea5d4966f 100644
--- a/src/org/traccar/api/BaseObjectResource.java
+++ b/src/org/traccar/api/BaseObjectResource.java
@@ -34,7 +34,7 @@ import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.model.User;
-public class BaseObjectResource<T extends BaseModel> extends BaseResource {
+public abstract class BaseObjectResource<T extends BaseModel> extends BaseResource {
private Class<T> baseClass;
@@ -57,8 +57,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
if (manager instanceof SimpleObjectManager) {
((SimpleObjectManager<T>) manager).refreshUserItems();
- }
- if (baseClass.equals(Group.class) || baseClass.equals(Device.class)) {
+ } else if (baseClass.equals(Group.class) || baseClass.equals(Device.class)) {
Context.getPermissionsManager().refreshDeviceAndGroupPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
}
@@ -71,8 +70,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
Context.getPermissionsManager().checkReadonly(getUserId());
if (baseClass.equals(Device.class)) {
Context.getPermissionsManager().checkDeviceReadonly(getUserId());
- }
- if (baseClass.equals(User.class)) {
+ } else if (baseClass.equals(User.class)) {
User before = Context.getPermissionsManager().getUser(entity.getId());
Context.getPermissionsManager().checkUserUpdate(getUserId(), before, (User) entity);
}
@@ -83,8 +81,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
if (baseClass.equals(Group.class) || baseClass.equals(Device.class)) {
Context.getPermissionsManager().refreshDeviceAndGroupPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
- }
- if (baseClass.equals(User.class) && Context.getNotificationManager() != null) {
+ } else if (baseClass.equals(User.class) && Context.getNotificationManager() != null) {
Context.getNotificationManager().refresh();
}
return Response.ok(entity).build();
@@ -116,7 +113,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
Context.getPermissionsManager().refreshAllExtendedPermissions();
}
}
- // deprecated
+ // Next should be removed with Attribute Aliases
if (baseClass.equals(Device.class)) {
Context.getAliasesManager().removeDevice(id);
}