aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-22 18:27:12 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-22 18:27:12 +0500
commitd9c87071eb8d8270a777f5ec990dd1978c2f67c7 (patch)
treeaba2767c87e538ed185f160d481f775f3e32a440 /src/org/traccar/events
parent4cb47c38af63696470acdc91d7b7d01512f6b2e7 (diff)
downloadtraccar-server-d9c87071eb8d8270a777f5ec990dd1978c2f67c7.tar.gz
traccar-server-d9c87071eb8d8270a777f5ec990dd1978c2f67c7.tar.bz2
traccar-server-d9c87071eb8d8270a777f5ec990dd1978c2f67c7.zip
Use ternary operator for calendar
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index 089d1e0ef..516df9d69 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -60,10 +60,7 @@ public class GeofenceEventHandler extends BaseEventHandler {
Collection<Event> events = new ArrayList<>();
for (long geofenceId : newGeofences) {
long calendarId = ((Geofence) geofenceManager.getById(geofenceId)).getCalendarId();
- Calendar calendar = null;
- if (calendarId != 0) {
- calendar = (Calendar) Context.getCalendarManager().getById(calendarId);
- }
+ Calendar calendar = calendarId != 0 ? (Calendar) Context.getCalendarManager().getById(calendarId) : null;
if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
@@ -72,10 +69,7 @@ public class GeofenceEventHandler extends BaseEventHandler {
}
for (long geofenceId : oldGeofences) {
long calendarId = ((Geofence) geofenceManager.getById(geofenceId)).getCalendarId();
- Calendar calendar = null;
- if (calendarId != 0) {
- calendar = (Calendar) Context.getCalendarManager().getById(calendarId);
- }
+ Calendar calendar = calendarId != 0 ? (Calendar) Context.getCalendarManager().getById(calendarId) : null;
if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);