Skip to content
Snippets Groups Projects
Commit 912e1bd0 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Fixes most google checkstyle warnings.

parent 6d304474
Branches
Tags
No related merge requests found
Pipeline #46507 passed
Showing
with 77 additions and 75 deletions
...@@ -49,7 +49,7 @@ public abstract class AbstractDocumentStorageImpl<D, L> ...@@ -49,7 +49,7 @@ public abstract class AbstractDocumentStorageImpl<D, L>
protected abstract D getDocument(); protected abstract D getDocument();
/** /**
* Sets the current document * Sets the current document.
* *
* @param document the new document * @param document the new document
*/ */
...@@ -99,11 +99,11 @@ public abstract class AbstractDocumentStorageImpl<D, L> ...@@ -99,11 +99,11 @@ public abstract class AbstractDocumentStorageImpl<D, L>
} }
/** /**
* Creates an ImportStream from a location * Creates an InputStream from a location.
* *
* @param location * @param location the location
* @return * @return the location's InputStream
* @throws IOException * @throws IOException when the InputStream cannot be created
*/ */
protected abstract InputStream toInputStream(L location) throws IOException; protected abstract InputStream toInputStream(L location) throws IOException;
......
...@@ -79,15 +79,6 @@ public class FileMenuController { ...@@ -79,15 +79,6 @@ public class FileMenuController {
} }
} }
private void showExceptionDialog(final String message) {
final Alert alert = new Alert(AlertType.ERROR, message, ButtonType.CLOSE);
alert.showAndWait();
}
private void showExceptionDialog(final String message, final Exception e) {
showExceptionDialog(message + ": " + e.getLocalizedMessage());
}
void handleOpenAction(final File selection) { void handleOpenAction(final File selection) {
try { try {
documentStorage.openDocument(selection); documentStorage.openDocument(selection);
...@@ -97,6 +88,15 @@ public class FileMenuController { ...@@ -97,6 +88,15 @@ public class FileMenuController {
} }
} }
private void showExceptionDialog(final String message) {
final Alert alert = new Alert(AlertType.ERROR, message, ButtonType.CLOSE);
alert.showAndWait();
}
private void showExceptionDialog(final String message, final Exception e) {
showExceptionDialog(message + ": " + e.getLocalizedMessage());
}
private void showSaveExceptionDialog(final File location, final Exception e) { private void showSaveExceptionDialog(final File location, final Exception e) {
showExceptionDialog("Oops, problem saving to " + location, e); showExceptionDialog("Oops, problem saving to " + location, e);
} }
...@@ -177,7 +177,7 @@ public class FileMenuController { ...@@ -177,7 +177,7 @@ public class FileMenuController {
private TextInputDialog inputDialog; private TextInputDialog inputDialog;
@FXML @FXML
public void handleURLImportAction() { public void handleUrlImportAction() {
if (inputDialog == null) { if (inputDialog == null) {
inputDialog = new TextInputDialog(); inputDialog = new TextInputDialog();
} }
...@@ -191,7 +191,7 @@ public class FileMenuController { ...@@ -191,7 +191,7 @@ public class FileMenuController {
break; break;
} }
try { try {
if (handleURLImportAction(new URL(result.get()))) { if (handleUrlImportAction(new URL(result.get()))) {
break; break;
} }
inputDialog.setHeaderText("Problems reading it..."); inputDialog.setHeaderText("Problems reading it...");
...@@ -202,7 +202,7 @@ public class FileMenuController { ...@@ -202,7 +202,7 @@ public class FileMenuController {
} }
} }
boolean handleURLImportAction(final URL url) { boolean handleUrlImportAction(final URL url) {
for (final IDocumentImporter importer : documentStorage.getDocumentImporters()) { for (final IDocumentImporter importer : documentStorage.getDocumentImporters()) {
try (InputStream input = url.openStream()) { try (InputStream input = url.openStream()) {
importer.importDocument(input); importer.importDocument(input);
......
...@@ -14,8 +14,8 @@ public interface IDocumentImporter { ...@@ -14,8 +14,8 @@ public interface IDocumentImporter {
/** /**
* Loads a document from the input stream and sets it as the current document. * Loads a document from the input stream and sets it as the current document.
* *
* @param inputStream * @param inputStream the document to import
* @throws IOException * @throws IOException when the document cannot imported
*/ */
public void importDocument(InputStream inputStream) throws IOException; public void importDocument(InputStream inputStream) throws IOException;
} }
...@@ -15,9 +15,9 @@ public interface IDocumentLoader<D> { ...@@ -15,9 +15,9 @@ public interface IDocumentLoader<D> {
/** /**
* Loads and returns a new document from an InputStream * Loads and returns a new document from an InputStream
* *
* @param inputStream * @param inputStream the InputStream to load from
* @return * @return the loaded document
* @throws Exception * @throws Exception when the document couldn't be loaded
*/ */
public D loadDocument(InputStream inputStream) throws Exception; public D loadDocument(InputStream inputStream) throws Exception;
} }
...@@ -13,9 +13,9 @@ public interface IDocumentSaver<D, L> { ...@@ -13,9 +13,9 @@ public interface IDocumentSaver<D, L> {
/** /**
* Saves the provided document to the provided location * Saves the provided document to the provided location
* *
* @param document * @param document the document to save
* @param documentLocation * @param documentLocation the location to save to
* @throws Exception * @throws Exception when the document couldn't be saved
*/ */
public void saveDocument(D document, L documentLocation) throws Exception; public void saveDocument(D document, L documentLocation) throws Exception;
} }
...@@ -24,14 +24,14 @@ public interface IDocumentStorage<L> { ...@@ -24,14 +24,14 @@ public interface IDocumentStorage<L> {
/** /**
* Sets the current location (of the current document), can be used by a save-as action. * Sets the current location (of the current document), can be used by a save-as action.
* *
* @param documentLocation * @param documentLocation the new document location
*/ */
public void setDocumentLocation(L documentLocation); public void setDocumentLocation(L documentLocation);
/** /**
* Adds an IDocumentStorageListener that will be notified when the current location changes. * Adds an IDocumentStorageListener that will be notified when the current location changes.
* *
* @param documentStorageListener * @param documentStorageListener the listener to add
*/ */
public void addDocumentStorageListener(IDocumentStorageListener<L> documentStorageListener); public void addDocumentStorageListener(IDocumentStorageListener<L> documentStorageListener);
...@@ -39,7 +39,7 @@ public interface IDocumentStorage<L> { ...@@ -39,7 +39,7 @@ public interface IDocumentStorage<L> {
/** /**
* Removes an IDocumentStorageListener. * Removes an IDocumentStorageListener.
* *
* @param documentStorageListener * @param documentStorageListener the listener to remove
*/ */
public void removeDocumentStorageListener(IDocumentStorageListener<L> documentStorageListener); public void removeDocumentStorageListener(IDocumentStorageListener<L> documentStorageListener);
......
...@@ -6,7 +6,7 @@ package fxutil.doc; ...@@ -6,7 +6,7 @@ package fxutil.doc;
* *
* @author hal * @author hal
* *
* @param <L> * @param <L> the document location type
*/ */
public interface IDocumentStorageListener<L> { public interface IDocumentStorageListener<L> {
/** /**
......
package fxutil.doc; package fxutil.doc;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
public abstract class SimpleJsonFileStorageImpl<T> extends AbstractDocumentStorageImpl<T, File> public abstract class SimpleJsonFileStorageImpl<T> extends AbstractDocumentStorageImpl<T, File>
implements IDocumentStorage<File> { implements IDocumentStorage<File> {
......
...@@ -2,7 +2,10 @@ package simpleex.core; ...@@ -2,7 +2,10 @@ package simpleex.core;
public class LatLong { public class LatLong {
private final double latitude, longitude; public static final String SEPARATOR = ",";
private final double latitude;
private final double longitude;
public LatLong(final double latitude, final double longitude) { public LatLong(final double latitude, final double longitude) {
super(); super();
...@@ -10,7 +13,6 @@ public class LatLong { ...@@ -10,7 +13,6 @@ public class LatLong {
this.longitude = longitude; this.longitude = longitude;
} }
public final static String SEPARATOR = ",";
public double getLatitude() { public double getLatitude() {
return latitude; return latitude;
......
package simpleex.json; package simpleex.json;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationContext;
...@@ -8,6 +7,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer; ...@@ -8,6 +7,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import simpleex.core.LatLong; import simpleex.core.LatLong;
public class LatLongDeserializer extends JsonDeserializer<LatLong> { public class LatLongDeserializer extends JsonDeserializer<LatLong> {
......
package simpleex.json; package simpleex.json;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import simpleex.core.LatLong; import simpleex.core.LatLong;
public class LatLongSerializer extends JsonSerializer<LatLong> { public class LatLongSerializer extends JsonSerializer<LatLong> {
......
package simpleex.json; package simpleex.json;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import simpleex.core.LatLong; import simpleex.core.LatLong;
import simpleex.core.LatLongs; import simpleex.core.LatLongs;
......
package simpleex.json; package simpleex.json;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import simpleex.core.LatLong; import simpleex.core.LatLong;
import simpleex.core.LatLongs; import simpleex.core.LatLongs;
......
package simpleex.ui; package simpleex.ui;
import java.io.File;
import java.util.Optional;
import fxmapcontrol.Location; import fxmapcontrol.Location;
import fxmapcontrol.MapBase; import fxmapcontrol.MapBase;
import fxmapcontrol.MapItemsControl; import fxmapcontrol.MapItemsControl;
...@@ -9,6 +7,8 @@ import fxmapcontrol.MapNode; ...@@ -9,6 +7,8 @@ import fxmapcontrol.MapNode;
import fxmapcontrol.MapProjection; import fxmapcontrol.MapProjection;
import fxutil.doc.FileMenuController; import fxutil.doc.FileMenuController;
import fxutil.doc.IDocumentListener; import fxutil.doc.IDocumentListener;
import java.io.File;
import java.util.Optional;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Point2D; import javafx.geometry.Point2D;
......
package simpleex.ui; package simpleex.ui;
import fxutil.doc.AbstractDocumentStorageImpl;
import fxutil.doc.IDocumentImporter;
import fxutil.doc.IDocumentLoader;
import fxutil.doc.IDocumentPersistence;
import fxutil.doc.IDocumentStorage;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -9,11 +14,6 @@ import java.io.OutputStream; ...@@ -9,11 +14,6 @@ import java.io.OutputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import fxutil.doc.AbstractDocumentStorageImpl;
import fxutil.doc.IDocumentImporter;
import fxutil.doc.IDocumentLoader;
import fxutil.doc.IDocumentPersistence;
import fxutil.doc.IDocumentStorage;
import simpleex.core.LatLongs; import simpleex.core.LatLongs;
public class LatLongsApp { public class LatLongsApp {
......
package simpleex.ui; package simpleex.ui;
import java.io.File;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import fxutil.doc.IDocumentStorage; import fxutil.doc.IDocumentStorage;
import fxutil.doc.SimpleJsonFileStorageImpl; import fxutil.doc.SimpleJsonFileStorageImpl;
import java.io.File;
import simpleex.core.LatLong; import simpleex.core.LatLong;
import simpleex.core.LatLongs; import simpleex.core.LatLongs;
import simpleex.json.LatLongDeserializer; import simpleex.json.LatLongDeserializer;
......
package simpleex.json; package simpleex.json;
import java.io.IOException;
import org.junit.Assert;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
import org.junit.Assert;
public abstract class AbstractJsonTest { public abstract class AbstractJsonTest {
......
package simpleex.json; package simpleex.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import simpleex.core.LatLong; import simpleex.core.LatLong;
public class LatLongJsonTest extends AbstractJsonTest { public class LatLongJsonTest extends AbstractJsonTest {
......
package simpleex.json; package simpleex.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import simpleex.core.LatLong; import simpleex.core.LatLong;
import simpleex.core.LatLongs; import simpleex.core.LatLongs;
......
...@@ -3,14 +3,14 @@ package simpleex.ui; ...@@ -3,14 +3,14 @@ package simpleex.ui;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import fxmapcontrol.Location;
import fxmapcontrol.MapBase;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest; import org.testfx.framework.junit.ApplicationTest;
import fxmapcontrol.Location;
import fxmapcontrol.MapBase;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment