diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-27 15:41:18 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-27 15:41:18 +0500 |
commit | ec82098c6bc3c84672665552839a97ddb6771afc (patch) | |
tree | f5759e40bbf8f9e3a4cee79b9829b27dbbef47c6 /src/org/traccar | |
parent | cabe5b5df2c1d31cd5fd3eeccbea32fa79cf404c (diff) | |
download | traccar-server-ec82098c6bc3c84672665552839a97ddb6771afc.tar.gz traccar-server-ec82098c6bc3c84672665552839a97ddb6771afc.tar.bz2 traccar-server-ec82098c6bc3c84672665552839a97ddb6771afc.zip |
Replace getClassByName function to switch
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 862efbc91..07ad0be44 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -37,11 +37,17 @@ import liquibase.resource.ResourceAccessor; import org.traccar.Config; import org.traccar.helper.Log; +import org.traccar.model.Attribute; import org.traccar.model.AttributeAlias; import org.traccar.model.Device; +import org.traccar.model.Driver; import org.traccar.model.Event; +import org.traccar.model.Geofence; +import org.traccar.model.Group; +import org.traccar.model.ManagedUser; import org.traccar.model.Permission; import org.traccar.model.BaseModel; +import org.traccar.model.Calendar; import org.traccar.model.Position; import org.traccar.model.Server; import org.traccar.model.Statistics; @@ -269,8 +275,26 @@ public class DataManager { } public static Class<?> getClassByName(String name) throws ClassNotFoundException { - return Class.forName("org.traccar.model." - + name.substring(0, 1).toUpperCase() + name.replace("Id", "").substring(1)); + switch (name.toLowerCase().replace("id", "")) { + case "device": + return Device.class; + case "group": + return Group.class; + case "user": + return User.class; + case "manageduser": + return ManagedUser.class; + case "geofence": + return Geofence.class; + case "driver": + return Driver.class; + case "attribute": + return Attribute.class; + case "calendar": + return Calendar.class; + default: + throw new ClassNotFoundException(); + } } public static String makeNameId(Class<?> clazz) { |