Skip to content

Commit

Permalink
#368: some renaming and ctors removed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 2, 2017
1 parent 45670f8 commit 76f33e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
35 changes: 8 additions & 27 deletions src/main/java/org/cactoos/io/BytesOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public BytesOf(final Reader rdr, final Charset cset, final int max) {
*
* @param builder The source
*/
public BytesOf(final StringBuilder builder) {
public BytesOf(final CharSequence builder) {
this(builder, StandardCharsets.UTF_8);
}

Expand All @@ -112,29 +112,10 @@ public BytesOf(final StringBuilder builder) {
* @param builder The source
* @param cset The charset
*/
public BytesOf(final StringBuilder builder, final Charset cset) {
public BytesOf(final CharSequence builder, final Charset cset) {
this(() -> builder.toString().getBytes(cset));
}

/**
* Ctor.
*
* @param buffer The source
*/
public BytesOf(final StringBuffer buffer) {
this(buffer, StandardCharsets.UTF_8);
}

/**
* Ctor.
*
* @param buffer The source
* @param cset The charset
*/
public BytesOf(final StringBuffer buffer, final Charset cset) {
this(() -> buffer.toString().getBytes(cset));
}

/**
* Ctor.
*
Expand All @@ -157,20 +138,20 @@ public BytesOf(final char[] chars, final Charset cset) {
/**
* Ctor.
*
* @param string The source
* @param source The source
*/
public BytesOf(final String string) {
this(string, StandardCharsets.UTF_8);
public BytesOf(final String source) {
this(source, StandardCharsets.UTF_8);
}

/**
* Ctor.
*
* @param string The source
* @param source The source
* @param cset The charset
*/
public BytesOf(final String string, final Charset cset) {
this(() -> string.getBytes(cset));
public BytesOf(final String source, final Charset cset) {
this(() -> source.getBytes(cset));
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/cactoos/io/EmptyBytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@
*/
public final class EmptyBytes implements Bytes {

/**
* Empty array of bytes.
*/
private static final byte[] EMPTY = {};

@Override
public byte[] asBytes() {
return new byte[] {};
return EmptyBytes.EMPTY;
}

}

0 comments on commit 76f33e9

Please sign in to comment.