aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/events
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-13 09:39:22 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-13 09:39:22 -0700
commit33733f835e88a62c4a5259ab330723b88037adf1 (patch)
treef12c710dc4dd6c21a1434f3d699a2fcdd76bb0fa /src/main/java/org/traccar/handler/events
parentadbeacc62ecb91c94f6cfe7dea8e79b8f5e1c802 (diff)
downloadtrackermap-server-33733f835e88a62c4a5259ab330723b88037adf1.tar.gz
trackermap-server-33733f835e88a62c4a5259ab330723b88037adf1.tar.bz2
trackermap-server-33733f835e88a62c4a5259ab330723b88037adf1.zip
Simplify attribute check
Diffstat (limited to 'src/main/java/org/traccar/handler/events')
-rw-r--r--src/main/java/org/traccar/handler/events/FuelDropEventHandler.java4
-rw-r--r--src/main/java/org/traccar/handler/events/IgnitionEventHandler.java4
-rw-r--r--src/main/java/org/traccar/handler/events/MotionEventHandler.java2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java b/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java
index 2d105af3e..25ae1fadb 100644
--- a/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/FuelDropEventHandler.java
@@ -53,8 +53,8 @@ public class FuelDropEventHandler extends BaseEventHandler {
cacheManager, Keys.EVENT_FUEL_DROP_THRESHOLD, position.getDeviceId());
if (fuelDropThreshold > 0) {
Position lastPosition = cacheManager.getPosition(position.getDeviceId());
- if (position.getAttributes().containsKey(Position.KEY_FUEL_LEVEL)
- && lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_FUEL_LEVEL)) {
+ if (position.hasAttribute(Position.KEY_FUEL_LEVEL)
+ && lastPosition != null && lastPosition.hasAttribute(Position.KEY_FUEL_LEVEL)) {
double drop = lastPosition.getDouble(Position.KEY_FUEL_LEVEL)
- position.getDouble(Position.KEY_FUEL_LEVEL);
diff --git a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
index 6e411539c..3c5ac3545 100644
--- a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java
@@ -47,11 +47,11 @@ public class IgnitionEventHandler extends BaseEventHandler {
Map<Event, Position> result = null;
- if (position.getAttributes().containsKey(Position.KEY_IGNITION)) {
+ if (position.hasAttribute(Position.KEY_IGNITION)) {
boolean ignition = position.getBoolean(Position.KEY_IGNITION);
Position lastPosition = cacheManager.getPosition(position.getDeviceId());
- if (lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_IGNITION)) {
+ if (lastPosition != null && lastPosition.hasAttribute(Position.KEY_IGNITION)) {
boolean oldIgnition = lastPosition.getBoolean(Position.KEY_IGNITION);
if (ignition && !oldIgnition) {
diff --git a/src/main/java/org/traccar/handler/events/MotionEventHandler.java b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
index bc9d5f722..1be1896ef 100644
--- a/src/main/java/org/traccar/handler/events/MotionEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MotionEventHandler.java
@@ -92,7 +92,7 @@ public class MotionEventHandler extends BaseEventHandler {
double distance = PositionUtil.calculateDistance(motionPosition, position, false);
Boolean ignition = null;
if (tripsConfig.getUseIgnition()
- && position.getAttributes().containsKey(Position.KEY_IGNITION)) {
+ && position.hasAttribute(Position.KEY_IGNITION)) {
ignition = position.getBoolean(Position.KEY_IGNITION);
}
if (newMotion) {