From 494ae8b29c59894dd18f1a9e5507ed2b3d92a223 Mon Sep 17 00:00:00 2001 From: Daniel Schramm <xschramm@fi.muni.cz> Date: Wed, 5 May 2021 14:39:07 +0200 Subject: [PATCH] Feature points import/export service made static; Inappropriate Optimal return value changed --- .../services/FeaturePointImportExportService.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/MeshModel/src/main/java/cz/fidentis/analyst/feature/services/FeaturePointImportExportService.java b/MeshModel/src/main/java/cz/fidentis/analyst/feature/services/FeaturePointImportExportService.java index 8452e8c0..a6828897 100644 --- a/MeshModel/src/main/java/cz/fidentis/analyst/feature/services/FeaturePointImportExportService.java +++ b/MeshModel/src/main/java/cz/fidentis/analyst/feature/services/FeaturePointImportExportService.java @@ -15,14 +15,11 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; -import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Stream; @@ -36,7 +33,7 @@ public class FeaturePointImportExportService { private static final String COLUMN_DELIMETER = ","; private static final String CODE_PREFIX_DELIMETER = " "; - public Optional<List<FeaturePoint>> importFeaturePoints(String path, String fileName) { + public static List<FeaturePoint> importFeaturePoints(String path, String fileName) { FileResourcesUtils app = new FileResourcesUtils(); try (InputStreamReader streamReader = new InputStreamReader(app.getFileAsStream(path, fileName), StandardCharsets.UTF_8); @@ -66,7 +63,7 @@ public class FeaturePointImportExportService { ); points.add(point); } - return Optional.of(points); + return points; } catch (IOException e) { throw new FeaturePointException(String.format("Feature point cannot open file", fileName)); @@ -75,11 +72,11 @@ public class FeaturePointImportExportService { } } - private String getCode(String str) { + private static String getCode(String str) { return str.substring(0, str.indexOf(CODE_PREFIX_DELIMETER)); } - public void exportFeaturePoints(List<FeaturePoint> featurePointList, String objectName) throws FileNotFoundException, IOException { + public static void exportFeaturePoints(List<FeaturePoint> featurePointList, String objectName) throws FileNotFoundException, IOException { File csvOutputFile = new File(String.format("%s_landmarks.csv", objectName)); // CSV is a normal text file, need a writer try (BufferedWriter bw = new BufferedWriter(new FileWriter(csvOutputFile))) { -- GitLab