-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
801 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 15 additions & 14 deletions
29
java-io-base/src/main/java/internal/io/AndThenFileParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,46 @@ | ||
package internal.io; | ||
|
||
import lombok.NonNull; | ||
import nbbrd.io.FileParser; | ||
import nbbrd.io.function.IOFunction; | ||
import nbbrd.io.function.IOSupplier; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import java.util.function.Function; | ||
|
||
@lombok.AllArgsConstructor | ||
public class AndThenFileParser<T, V> implements FileParser<V> { | ||
|
||
@lombok.NonNull | ||
@NonNull | ||
protected final FileParser<T> parser; | ||
|
||
@lombok.NonNull | ||
protected final Function<? super T, ? extends V> after; | ||
@NonNull | ||
protected final IOFunction<? super T, ? extends V> after; | ||
|
||
@Override | ||
public V parseFile(File source) throws IOException { | ||
return after.apply(parser.parseFile(source)); | ||
public @NonNull V parseFile(@NonNull File source) throws IOException { | ||
return after.applyWithIO(parser.parseFile(source)); | ||
} | ||
|
||
@Override | ||
public V parsePath(Path source) throws IOException { | ||
return after.apply(parser.parsePath(source)); | ||
public @NonNull V parsePath(@NonNull Path source) throws IOException { | ||
return after.applyWithIO(parser.parsePath(source)); | ||
} | ||
|
||
@Override | ||
public V parseResource(Class<?> type, String name) throws IOException { | ||
return after.apply(parser.parseResource(type, name)); | ||
public @NonNull V parseResource(@NonNull Class<?> type, @NonNull String name) throws IOException { | ||
return after.applyWithIO(parser.parseResource(type, name)); | ||
} | ||
|
||
@Override | ||
public V parseStream(IOSupplier<? extends InputStream> source) throws IOException { | ||
return after.apply(parser.parseStream(source)); | ||
public @NonNull V parseStream(@NonNull IOSupplier<? extends InputStream> source) throws IOException { | ||
return after.applyWithIO(parser.parseStream(source)); | ||
} | ||
|
||
@Override | ||
public V parseStream(InputStream resource) throws IOException { | ||
return after.apply(parser.parseStream(resource)); | ||
public @NonNull V parseStream(@NonNull InputStream resource) throws IOException { | ||
return after.applyWithIO(parser.parseStream(resource)); | ||
} | ||
} |
30 changes: 13 additions & 17 deletions
30
java-io-base/src/main/java/internal/io/ComposeFileFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,41 @@ | ||
package internal.io; | ||
|
||
import lombok.NonNull; | ||
import nbbrd.io.FileFormatter; | ||
import nbbrd.io.function.IOFunction; | ||
import nbbrd.io.function.IOSupplier; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.file.Path; | ||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
@lombok.AllArgsConstructor | ||
public class ComposeFileFormatter<V, T> implements FileFormatter<V> { | ||
|
||
@lombok.NonNull | ||
@NonNull | ||
protected final FileFormatter<T> formatter; | ||
|
||
@lombok.NonNull | ||
protected final Function<? super V, ? extends T> before; | ||
@NonNull | ||
protected final IOFunction<? super V, ? extends T> before; | ||
|
||
@Override | ||
public void formatFile(V value, File target) throws IOException { | ||
Objects.requireNonNull(value, "value"); | ||
formatter.formatFile(before.apply(value), target); | ||
public void formatFile(@NonNull V value, @NonNull File target) throws IOException { | ||
formatter.formatFile(before.applyWithIO(value), target); | ||
} | ||
|
||
@Override | ||
public void formatPath(V value, Path target) throws IOException { | ||
Objects.requireNonNull(value, "value"); | ||
formatter.formatPath(before.apply(value), target); | ||
public void formatPath(@NonNull V value, @NonNull Path target) throws IOException { | ||
formatter.formatPath(before.applyWithIO(value), target); | ||
} | ||
|
||
@Override | ||
public void formatStream(V value, IOSupplier<? extends OutputStream> target) throws IOException { | ||
Objects.requireNonNull(value, "value"); | ||
formatter.formatStream(before.apply(value), target); | ||
public void formatStream(@NonNull V value, @NonNull IOSupplier<? extends OutputStream> target) throws IOException { | ||
formatter.formatStream(before.applyWithIO(value), target); | ||
} | ||
|
||
@Override | ||
public void formatStream(V value, OutputStream resource) throws IOException { | ||
Objects.requireNonNull(value, "value"); | ||
formatter.formatStream(before.apply(value), resource); | ||
public void formatStream(@NonNull V value, @NonNull OutputStream resource) throws IOException { | ||
formatter.formatStream(before.applyWithIO(value), resource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
java-io-base/src/main/java/internal/io/FunctionalFileFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
package internal.io; | ||
|
||
import lombok.NonNull; | ||
import nbbrd.io.FileFormatter; | ||
import nbbrd.io.function.IOBiConsumer; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.Objects; | ||
|
||
@lombok.RequiredArgsConstructor | ||
public final class FunctionalFileFormatter<T> implements FileFormatter<T> { | ||
|
||
@lombok.NonNull | ||
@NonNull | ||
private final IOBiConsumer<? super T, ? super OutputStream> function; | ||
|
||
@Override | ||
public void formatStream(@NonNull T value, @NonNull OutputStream resource) throws IOException { | ||
Objects.requireNonNull(value, "value"); | ||
Objects.requireNonNull(resource, "resource"); | ||
function.acceptWithIO(value, resource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.