From eb58c3f3b3392316e22bb4f89de4162887135c5c Mon Sep 17 00:00:00 2001
From: Hallvard Traetteberg <hal@ntnu.no>
Date: Thu, 29 Aug 2019 07:55:31 +0200
Subject: [PATCH] Remove use of Optional and isEmpty

---
 .../src/main/java/simpleex/core/LatLong.java  |  1 -
 .../java/simpleex/ui/FxAppController.java     | 22 +++++++++----------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/simpleexample/src/main/java/simpleex/core/LatLong.java b/simpleexample/src/main/java/simpleex/core/LatLong.java
index 438f188..68d10a1 100644
--- a/simpleexample/src/main/java/simpleex/core/LatLong.java
+++ b/simpleexample/src/main/java/simpleex/core/LatLong.java
@@ -13,7 +13,6 @@ public class LatLong {
     this.longitude = longitude;
   }
 
-
   public double getLatitude() {
     return latitude;
   }
diff --git a/simpleexample/src/main/java/simpleex/ui/FxAppController.java b/simpleexample/src/main/java/simpleex/ui/FxAppController.java
index 134d375..c004440 100644
--- a/simpleexample/src/main/java/simpleex/ui/FxAppController.java
+++ b/simpleexample/src/main/java/simpleex/ui/FxAppController.java
@@ -12,7 +12,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Optional;
 import javafx.collections.FXCollections;
 import javafx.event.ActionEvent;
 import javafx.fxml.FXML;
@@ -73,7 +72,7 @@ public class FxAppController {
   private MapBase mapView;
 
   private MapItemsControl<MapNode> markersParent;
-  private Optional<MapMarker> marker = Optional.empty();
+  private MapMarker marker = null;
   private DraggableNodeController draggableMapController = null;
   private DraggableNodeController draggableMarkerController = null;
 
@@ -107,7 +106,7 @@ public class FxAppController {
 
   private void handleMarkerDragged(final Node node, final double dx, final double dy) {
     final MapProjection projection = mapView.getProjection();
-    final Point2D point = projection.locationToViewportPoint(marker.get().getLocation());
+    final Point2D point = projection.locationToViewportPoint(marker.getLocation());
     final Location newLocation = projection.viewportPointToLocation(point.add(dx, dy));
     getLatLongs().setLatLong(locationListView.getSelectionModel().getSelectedIndex(),
         location2LatLong(newLocation));
@@ -123,23 +122,22 @@ public class FxAppController {
     if (num < 0 || num >= getLatLongs().getLatLongCount()) {
       markersParent.getItems().clear();
       if (draggableMarkerController != null) {
-        draggableMarkerController.detach(marker.get());
+        draggableMarkerController.detach(marker);
       }
-      marker = Optional.empty();
+      marker = null;
     } else {
       final LatLong latLong = getLatLongs().getLatLong(num);
-      if (marker.isEmpty()) {
-        final MapMarker aMarker = new MapMarker(latLong);
-        markersParent.getItems().add(aMarker);
+      if (marker == null) {
+        marker = new MapMarker(latLong);
+        markersParent.getItems().add(marker);
         if (draggableMarkerController != null) {
-          draggableMarkerController.attach(aMarker);
+          draggableMarkerController.attach(marker);
         }
-        marker = Optional.of(aMarker);
       } else {
-        marker.get().setLocation(latLong);
+        marker.setLocation(latLong);
       }
       if (centerOnMarker) {
-        mapView.setCenter(marker.get().getLocation());
+        mapView.setCenter(marker.getLocation());
       }
     }
   }
-- 
GitLab