mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
removed some code smells
This commit is contained in:
@@ -29,7 +29,6 @@ package ninja.javafx.smartcsv.export;
|
|||||||
import javafx.concurrent.Service;
|
import javafx.concurrent.Service;
|
||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import ninja.javafx.smartcsv.fx.table.model.CSVModel;
|
import ninja.javafx.smartcsv.fx.table.model.CSVModel;
|
||||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ValueTextField extends TextField {
|
private static class ValueTextField extends TextField {
|
||||||
private CSVValue value;
|
private CSVValue value;
|
||||||
|
|
||||||
public ValueTextField(CSVValue value) {
|
public ValueTextField(CSVValue value) {
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public class ObservableMapValueFactory implements
|
|||||||
@Override
|
@Override
|
||||||
public ObjectProperty<CSVValue> call(TableColumn.CellDataFeatures<CSVRow, CSVValue> features) {
|
public ObjectProperty<CSVValue> call(TableColumn.CellDataFeatures<CSVRow, CSVValue> features) {
|
||||||
CSVRow row = features.getValue();
|
CSVRow row = features.getValue();
|
||||||
ObjectProperty<CSVValue> value = row.getColumns().get(key);
|
return row.getColumns().get(key);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import static ninja.javafx.smartcsv.preferences.QuoteModeHelper.getQuoteMode;
|
|||||||
*/
|
*/
|
||||||
public class PreferencesFileReader implements FileReader<CsvPreference> {
|
public class PreferencesFileReader implements FileReader<CsvPreference> {
|
||||||
|
|
||||||
private Map config;
|
|
||||||
private CsvPreference csvPreference;
|
private CsvPreference csvPreference;
|
||||||
|
|
||||||
public PreferencesFileReader() {
|
public PreferencesFileReader() {
|
||||||
@@ -54,14 +53,14 @@ public class PreferencesFileReader implements FileReader<CsvPreference> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(File filename) throws IOException {
|
public void read(File filename) throws IOException {
|
||||||
config = new GsonBuilder().create().fromJson(new java.io.FileReader(filename), HashMap.class);
|
Map config = new GsonBuilder().create().fromJson(new java.io.FileReader(filename), HashMap.class);
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
char quoteChar = config.get("quoteChar").toString().charAt(0);
|
char quoteChar = config.get("quoteChar").toString().charAt(0);
|
||||||
char delimiterChar = config.get("delimiterChar").toString().charAt(0);
|
char delimiterChar = config.get("delimiterChar").toString().charAt(0);
|
||||||
String endOfLineSymbols = config.get("endOfLineSymbols").toString();
|
String endOfLineSymbols = config.get("endOfLineSymbols").toString();
|
||||||
boolean surroundingSpacesNeedQuotes = (Boolean)config.get("surroundingSpacesNeedQuotes");
|
boolean surroundingSpacesNeedQuotes = (Boolean) config.get("surroundingSpacesNeedQuotes");
|
||||||
boolean ignoreEmptyLines = (Boolean)config.get("ignoreEmptyLines");
|
boolean ignoreEmptyLines = (Boolean) config.get("ignoreEmptyLines");
|
||||||
String quoteMode = config.get("quoteMode").toString();
|
String quoteMode = config.get("quoteMode").toString();
|
||||||
|
|
||||||
csvPreference = new CsvPreference.Builder(quoteChar, delimiterChar, endOfLineSymbols)
|
csvPreference = new CsvPreference.Builder(quoteChar, delimiterChar, endOfLineSymbols)
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ import org.codehaus.groovy.control.CompilationFailedException;
|
|||||||
public class GroovyValidation extends EmptyValueIsValid {
|
public class GroovyValidation extends EmptyValueIsValid {
|
||||||
|
|
||||||
private String groovyScript;
|
private String groovyScript;
|
||||||
private GroovyShell shell = new GroovyShell();
|
|
||||||
private Script script;
|
private Script script;
|
||||||
|
|
||||||
public GroovyValidation(String groovyScript) {
|
public GroovyValidation(String groovyScript) {
|
||||||
this.groovyScript = groovyScript;
|
this.groovyScript = groovyScript;
|
||||||
|
GroovyShell shell = new GroovyShell();
|
||||||
script = shell.parse(groovyScript);
|
script = shell.parse(groovyScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class UuidValidation extends EmptyValueIsValid {
|
public class UuidValidation extends EmptyValueIsValid {
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
@Override
|
@Override
|
||||||
public void check(int row, String value, ValidationError error) {
|
public void check(int row, String value, ValidationError error) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ package ninja.javafx.smartcsv.preferences;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
import static java.util.stream.Collectors.joining;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -115,6 +114,7 @@ public class HeaderValidationTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("StringConcatenationInLoop")
|
||||||
public static String json(String... headerNames) {
|
public static String json(String... headerNames) {
|
||||||
|
|
||||||
String json = "{ \"fields\": [";
|
String json = "{ \"fields\": [";
|
||||||
|
|||||||
Reference in New Issue
Block a user