garydgregory commented on code in PR #821:
URL: https://github.com/apache/commons-compress/pull/821#discussion_r4206305722
##########
src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java:
##########
@@ -35,9 +36,76 @@
*/
public class BrotliCompressorInputStream extends CompressorInputStream
implements InputStreamStatistics {
+ // @formatter:off
+ /**
+ * Builds a new {@link BrotliCompressorInputStream}.
+ *
+ * <p>
+ * For example:
+ * </p>
+ * <pre>{@code
+ * BrotliCompressorInputStream s = BrotliCompressorInputStream.builder()
+ * .setPath(path)
+ * .setDict(dictionary)
+ * .get();
+ * }
+ * </pre>
+ *
+ * @see #get()
+ * @since 1.29.0
+ */
+ // @formatter:on
+ public static final class Builder extends
AbstractStreamBuilder<BrotliCompressorInputStream, Builder> {
+
+ private byte[] dict;
+
+ /**
+ * Constructs a new builder of {@link BrotliCompressorInputStream}.
+ */
+ public Builder() {
+ // empty
+ }
+
+ @Override
+ public BrotliCompressorInputStream get() throws IOException {
+ return new BrotliCompressorInputStream(this);
+ }
+
+ /**
+ * Sets the raw (LZ77) dictionary used to decompress the input.
+ * <p>
+ * The input must have been compressed with the same raw dictionary,
which acts as data preceding the stream. The value {@code null} means no
+ * dictionary.
+ * </p>
+ *
+ * @param dict The dictionary buffer.
+ * @return {@code this} instance.
+ */
+ public Builder setDict(final byte[] dict) {
+ this.dict = dict;
Review Comment:
Should the builder track a defensive copy?
##########
src/main/java/org/apache/commons/compress/compressors/zstandard/ZstdCompressorInputStream.java:
##########
@@ -44,9 +45,80 @@
*/
public class ZstdCompressorInputStream extends CompressorInputStream
implements InputStreamStatistics {
+ // @formatter:off
+ /**
+ * Builds a new {@link ZstdCompressorInputStream}.
+ *
+ * <p>
+ * For example:
+ * </p>
+ * <pre>{@code
+ * ZstdCompressorInputStream s = ZstdCompressorInputStream.builder()
+ * .setPath(path)
+ * .setDict(dictionary)
+ * .get();
+ * }
+ * </pre>
+ *
+ * @see #get()
+ * @since 1.29.0
+ */
+ // @formatter:on
+ public static final class Builder extends
AbstractStreamBuilder<ZstdCompressorInputStream, Builder> {
+
+ private byte[] dict;
+
+ /**
+ * Constructs a new builder of {@link ZstdCompressorInputStream}.
+ */
+ public Builder() {
+ // empty
+ }
+
+ @Override
+ public ZstdCompressorInputStream get() throws IOException {
+ return new ZstdCompressorInputStream(this);
+ }
+
+ /**
+ * Sets the dictionary used to decompress the input.
+ * <p>
+ * The input must have been compressed with the same dictionary, for
example with {@link ZstdCompressorOutputStream.Builder#setDict(byte[])}. The
+ * dictionary may be a trained Zstandard dictionary or raw content.
The value {@code null} means no dictionary.
+ * </p>
+ *
+ * @param dict The dictionary buffer.
+ * @return {@code this} instance.
+ * @see <a
href="https://facebook.github.io/zstd/zstd_manual.html#Chapter14">Zstd manual
Chapter14</a>
+ */
+ public Builder setDict(final byte[] dict) {
+ this.dict = dict;
Review Comment:
Should the builder track a defensive copy?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]