aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-07-19 06:52:57 +0500
committerAbyss777 <abyss@fox5.ru>2016-07-19 06:52:57 +0500
commit53b5d27767ff03da241c21e83b2cb2e12fcda60c (patch)
tree05380184edb5fe3aace6525d3ca686639c2f69ce /src/org/traccar
parent919329b4a96247ca52e94b028589b8556615d456 (diff)
downloadtrackermap-server-53b5d27767ff03da241c21e83b2cb2e12fcda60c.tar.gz
trackermap-server-53b5d27767ff03da241c21e83b2cb2e12fcda60c.tar.bz2
trackermap-server-53b5d27767ff03da241c21e83b2cb2e12fcda60c.zip
Remove unnecessary checks and use cast instead toString()
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/TotemProtocolEncoder.java10
-rw-r--r--src/org/traccar/protocol/WondexProtocolEncoder.java10
2 files changed, 8 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolEncoder.java b/src/org/traccar/protocol/TotemProtocolEncoder.java
index fb8e762c5..1c870f63c 100644
--- a/src/org/traccar/protocol/TotemProtocolEncoder.java
+++ b/src/org/traccar/protocol/TotemProtocolEncoder.java
@@ -28,12 +28,10 @@ public class TotemProtocolEncoder extends StringProtocolEncoder {
protected Object encodeCommand(Command command) {
command.set(Command.KEY_DEVICE_PASSWORD, "000000");
- if (Context.getDeviceManager() != null) {
- Device device = Context.getDeviceManager().getDeviceById(command.getDeviceId());
- if (device != null && device.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) {
- command.set(Command.KEY_DEVICE_PASSWORD, device.getAttributes()
- .get(Command.KEY_DEVICE_PASSWORD).toString());
- }
+ Device device = Context.getIdentityManager().getDeviceById(command.getDeviceId());
+ if (device.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) {
+ command.set(Command.KEY_DEVICE_PASSWORD, (String) device.getAttributes()
+ .get(Command.KEY_DEVICE_PASSWORD));
}
switch (command.getType()) {
diff --git a/src/org/traccar/protocol/WondexProtocolEncoder.java b/src/org/traccar/protocol/WondexProtocolEncoder.java
index 7a323e4a8..568ca6aa0 100644
--- a/src/org/traccar/protocol/WondexProtocolEncoder.java
+++ b/src/org/traccar/protocol/WondexProtocolEncoder.java
@@ -11,12 +11,10 @@ public class WondexProtocolEncoder extends StringProtocolEncoder {
protected Object encodeCommand(Command command) {
command.set(Command.KEY_DEVICE_PASSWORD, "0000");
- if (Context.getDeviceManager() != null) {
- Device device = Context.getDeviceManager().getDeviceById(command.getDeviceId());
- if (device != null && device.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) {
- command.set(Command.KEY_DEVICE_PASSWORD, device.getAttributes()
- .get(Command.KEY_DEVICE_PASSWORD).toString());
- }
+ Device device = Context.getIdentityManager().getDeviceById(command.getDeviceId());
+ if (device.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) {
+ command.set(Command.KEY_DEVICE_PASSWORD, (String) device.getAttributes()
+ .get(Command.KEY_DEVICE_PASSWORD));
}
switch (command.getType()) {