Skip to content

Commit 9f444b4

Browse files
committed
BaseNCodecInputStream subclasses are now type-safe to match its matching
BaseNCodec
1 parent 3c84e5f commit 9f444b4

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The <action> type attribute can be add,update,fix,remove.
4747
<!-- FIX -->
4848
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate all but one Base32 constructor in favor of the builder added in version 1.17.0.</action>
4949
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate all but one Base64 constructor in favor of the builder added in version 1.17.0.</action>
50+
<action type="update" dev="ggregory" due-to="Gary Gregory">BaseNCodecInputStream subclasses are now type-safe to match its matching BaseNCodec.</action>
5051
<!-- ADD -->
5152
<action type="add" dev="ggregory" due-to="Fredrik Kjellberg, Gary Gregory">Add org.apache.commons.codec.digest.CRC16.</action>
5253
<!-- UPDATE -->

src/main/java/org/apache/commons/codec/binary/Base16InputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @see Base16
3232
* @since 1.15
3333
*/
34-
public class Base16InputStream extends BaseNCodecInputStream {
34+
public class Base16InputStream extends BaseNCodecInputStream<Base16> {
3535

3636
/**
3737
* Constructs a Base16InputStream such that all data read is Base16-decoded from the original provided InputStream.

src/main/java/org/apache/commons/codec/binary/Base32InputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* @see <a href="http://www.ietf.org/rfc/rfc4648.txt">RFC 4648</a>
5555
* @since 1.5
5656
*/
57-
public class Base32InputStream extends BaseNCodecInputStream {
57+
public class Base32InputStream extends BaseNCodecInputStream<Base32> {
5858

5959
/**
6060
* Constructs a Base32InputStream such that all data read is Base32-decoded from the original provided InputStream.

src/main/java/org/apache/commons/codec/binary/Base64InputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
5959
* @since 1.4
6060
*/
61-
public class Base64InputStream extends BaseNCodecInputStream {
61+
public class Base64InputStream extends BaseNCodecInputStream<Base64> {
6262

6363
/**
6464
* Constructs a Base64InputStream such that all data read is Base64-decoded from the original provided InputStream.

src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
import org.apache.commons.codec.binary.BaseNCodec.Context;
2828

2929
/**
30-
* Abstract superclass for Base-N input streams.
30+
* Abstracts Base-N input streams.
3131
*
32+
* @param <T> A BaseNCodec subclass.
33+
* @see Base16InputStream
34+
* @see Base32InputStream
35+
* @see Base64InputStream
3236
* @since 1.5
3337
*/
34-
public class BaseNCodecInputStream extends FilterInputStream {
38+
public class BaseNCodecInputStream<T extends BaseNCodec> extends FilterInputStream {
3539

36-
private final BaseNCodec baseNCodec;
40+
private final T baseNCodec;
3741

3842
private final boolean doEncode;
3943

@@ -50,7 +54,7 @@ public class BaseNCodecInputStream extends FilterInputStream {
5054
* @param baseNCodec the codec.
5155
* @param doEncode set to true to perform encoding, else decoding.
5256
*/
53-
protected BaseNCodecInputStream(final InputStream inputStream, final BaseNCodec baseNCodec, final boolean doEncode) {
57+
protected BaseNCodecInputStream(final InputStream inputStream, final T baseNCodec, final boolean doEncode) {
5458
super(inputStream);
5559
this.doEncode = doEncode;
5660
this.baseNCodec = baseNCodec;

0 commit comments

Comments
 (0)