Skip to content

Commit 4272563

Browse files
committed
BaseNCodecOutputStream subclasses are now type-safe to match its
matching BaseNCodec
1 parent 9f444b4 commit 4272563

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The <action> type attribute can be add,update,fix,remove.
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>
5050
<action type="update" dev="ggregory" due-to="Gary Gregory">BaseNCodecInputStream subclasses are now type-safe to match its matching BaseNCodec.</action>
51+
<action type="update" dev="ggregory" due-to="Gary Gregory">BaseNCodecOutputStream subclasses are now type-safe to match its matching BaseNCodec.</action>
5152
<!-- ADD -->
5253
<action type="add" dev="ggregory" due-to="Fredrik Kjellberg, Gary Gregory">Add org.apache.commons.codec.digest.CRC16.</action>
5354
<!-- UPDATE -->

src/main/java/org/apache/commons/codec/binary/Base16OutputStream.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 Base16OutputStream extends BaseNCodecOutputStream {
34+
public class Base16OutputStream extends BaseNCodecOutputStream<Base16> {
3535

3636
/**
3737
* Constructs a Base16OutputStream such that all data written is Base16-encoded to the original provided OutputStream.

src/main/java/org/apache/commons/codec/binary/Base32OutputStream.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/rfc4648.txt">RFC 4648</a>
5959
* @since 1.5
6060
*/
61-
public class Base32OutputStream extends BaseNCodecOutputStream {
61+
public class Base32OutputStream extends BaseNCodecOutputStream<Base32> {
6262

6363
/**
6464
* Constructs a Base32OutputStream such that all data written is Base32-encoded to the original provided OutputStream.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
6363
* @since 1.4
6464
*/
65-
public class Base64OutputStream extends BaseNCodecOutputStream {
65+
public class Base64OutputStream extends BaseNCodecOutputStream<Base64> {
6666

6767
/**
6868
* Constructs a Base64OutputStream such that all data written is Base64-encoded to the original provided OutputStream.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
* >CloseShieldOutputStream</a>.
3636
* </p>
3737
*
38+
* @param <T> A BaseNCodec subclass.
3839
* @since 1.5
3940
*/
40-
public class BaseNCodecOutputStream extends FilterOutputStream {
41+
public class BaseNCodecOutputStream<T extends BaseNCodec> extends FilterOutputStream {
4142

4243
private final boolean doEncode;
4344

44-
private final BaseNCodec baseNCodec;
45+
private final T baseNCodec;
4546

4647
private final byte[] singleByte = new byte[1];
4748

@@ -56,7 +57,7 @@ public class BaseNCodecOutputStream extends FilterOutputStream {
5657
* @param basedCodec a BaseNCodec.
5758
* @param doEncode true to encode, false to decode, TODO should be an enum?
5859
*/
59-
public BaseNCodecOutputStream(final OutputStream outputStream, final BaseNCodec basedCodec, final boolean doEncode) {
60+
public BaseNCodecOutputStream(final OutputStream outputStream, final T basedCodec, final boolean doEncode) {
6061
super(outputStream);
6162
this.baseNCodec = basedCodec;
6263
this.doEncode = doEncode;

0 commit comments

Comments
 (0)