Skip to content

Commit

Permalink
feat: Codec add composition helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Jan 13, 2025
1 parent 7dde5bb commit a791244
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/janelia/saalfeldlab/n5/codec/Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
@NameConfig.Prefix("codec")
public interface Codec extends Serializable {

public static OutputStream encode(OutputStream out, Codec.BytesCodec... bytesCodecs) throws IOException {
OutputStream stream = out;
for (final BytesCodec codec : bytesCodecs)
stream = codec.encode(stream);

return stream;
}

public static InputStream decode(InputStream out, Codec.BytesCodec... bytesCodecs) throws IOException {
InputStream stream = out;
for (final BytesCodec codec : bytesCodecs)
stream = codec.decode(stream);

return stream;
}

public interface BytesCodec extends Codec {

/**
Expand Down

0 comments on commit a791244

Please sign in to comment.