Skip to content

Commit

Permalink
Fixed some issues in CSV compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
colorizenl committed Apr 1, 2024
1 parent 706c784 commit 35f7cd7
Show file tree
Hide file tree
Showing 20 changed files with 670 additions and 482 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "io.freefair.lombok" version "8.4"
id "io.freefair.lombok" version "8.6"
id "com.github.ben-manes.versions" version "0.51.0"
}

Expand All @@ -9,7 +9,7 @@ apply plugin: "maven-publish"
apply plugin: "signing"

group = "nl.colorize"
version = "2024.3"
version = "2024.4"
compileJava.options.encoding = "UTF-8"

java {
Expand All @@ -27,8 +27,8 @@ repositories {
}

dependencies {
api "com.google.guava:guava:33.0.0-jre"
testImplementation "org.junit.jupiter:junit-jupiter:5.10.1"
api "com.google.guava:guava:33.1.0-jre"
testImplementation "org.junit.jupiter:junit-jupiter:5.10.2"
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}

Expand Down
7 changes: 2 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ to the dependencies section in `pom.xml`:
<dependency>
<groupId>nl.colorize</groupId>
<artifactId>colorize-java-commons</artifactId>
<version>2024.3</version>
<version>2024.4</version>
</dependency>

The library can also be used in Gradle projects:

dependencies {
implementation "nl.colorize:colorize-java-commons:2024.3"
implementation "nl.colorize:colorize-java-commons:2024.4"
}

Documentation
Expand All @@ -62,9 +62,6 @@ The following example shows how to define a simple command line interface:
@Arg(name = "--input", usage = "Input directory")
public File inputDir

@Arg(name = "--output", defaultValue = "/tmp", usage = ""Output directory")
public File outputDir;

@Arg
public boolean overwrite;

Expand Down
1 change: 1 addition & 0 deletions resources/custom-swing-components.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ PropertyEditor.cancel=Cancel

ImageViewer.imageFile=Image file
ImageViewer.imageFileSize=File size
ImageViewer.imageSize=Size
226 changes: 0 additions & 226 deletions source/nl/colorize/util/CSVRecord.java

This file was deleted.

30 changes: 30 additions & 0 deletions source/nl/colorize/util/PropertyDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package nl.colorize.util;

import com.google.common.base.Preconditions;
import nl.colorize.util.stats.CSVRecord;

import java.io.File;
import java.nio.file.Path;
Expand Down Expand Up @@ -223,4 +224,33 @@ public static PropertyDeserializer fromProperties(Properties properties) {
propertyDeserializer.registerPreprocessor(properties::getProperty);
return propertyDeserializer;
}

/**
* Returns a {@link PropertyDeserializer} that acts as a live view for
* parsing values from the specified map.
*/
public static PropertyDeserializer fromMap(Map<String, ?> properties) {
PropertyDeserializer propertyDeserializer = new PropertyDeserializer();
propertyDeserializer.registerPreprocessor(name -> {
Object value = properties.get(name);
return value != null ? value.toString() : null;
});
return propertyDeserializer;
}

/**
* Returns a {@link PropertyDeserializer} that acts as a live view for
* parsing values from the specified CSV record.
*
* @throws IllegalStateException if the CSV does not include any column
* information.
*/
public static PropertyDeserializer fromCSV(CSVRecord record) {
Preconditions.checkState(record.hasColumnInformation(),
"CSV does not include column information");

PropertyDeserializer propertyDeserializer = new PropertyDeserializer();
propertyDeserializer.registerPreprocessor(record::get);
return propertyDeserializer;
}
}
Loading

0 comments on commit 35f7cd7

Please sign in to comment.