Skip to content

Commit 37bc5de

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents f762bb4 + 7153117 commit 37bc5de

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Bytes is a utility library that makes it easy to **create**, **parse**, **transform**,
44
**validate** and **convert** byte arrays in Java. It's main class `Bytes` is
55
a collections of bytes and the main API. It supports [endianness](https://en.wikipedia.org/wiki/Endianness)
6-
as well as **immutable** and **mutable** access, so the caller may decide to favor
6+
as well as **copy-on-write** and **mutable** access, so the caller may decide to favor
77
performance. This can be seen as combination of the features provided by
88
[`BigInteger`](https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html),
99
[`ByteBuffer`](https://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html) but
@@ -80,7 +80,7 @@ byte[] result = b.array(); //get as byte array
8080

8181
## API Description
8282

83-
Per default the instance is **immutable**, which means any transformation will
83+
Per default the instance is **semi-immutable**, which means any transformation will
8484
create a copy of the internal array (it is, however, possible to get and
8585
modify the internal array). There is a **mutable** version which supports
8686
in-place modification for better performance and a **read-only** version which

src/main/java/at/favre/lib/bytes/Bytes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ public Bytes byteOrder(ByteOrder byteOrder) {
14401440

14411441
/**
14421442
* Returns a new read-only byte instance. Read-only means, that there is no direct access to the underlying byte
1443-
* array and all transformers will create a copy (ie. immutable)
1443+
* array and all transformers will create a copy.
14441444
*
14451445
* @return a new instance if not already readonly, or "this" otherwise
14461446
*/

src/main/java/at/favre/lib/bytes/MutableBytes.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public boolean isMutable() {
5151
* @throws IndexOutOfBoundsException if newArray.length > internal length
5252
*/
5353
public MutableBytes overwrite(byte[] newArray) {
54-
overwrite(newArray, 0);
55-
return this;
54+
return overwrite(newArray, 0);
5655
}
5756

5857
/**
@@ -87,8 +86,7 @@ public MutableBytes setByteAt(int index, byte newByte) {
8786
* @return this instance
8887
*/
8988
public MutableBytes wipe() {
90-
fill((byte) 0);
91-
return this;
89+
return fill((byte) 0);
9290
}
9391

9492
/**
@@ -108,8 +106,7 @@ public MutableBytes fill(byte fillByte) {
108106
* @return this instance
109107
*/
110108
public MutableBytes secureWipe() {
111-
secureWipe(new SecureRandom());
112-
return this;
109+
return secureWipe(new SecureRandom());
113110
}
114111

115112
/**

src/main/java/at/favre/lib/bytes/ReadOnlyBytes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public final class ReadOnlyBytes extends Bytes {
3535

3636
/**
37-
* Creates a new immutable instance
37+
* Creates a new read-only instance
3838
*
3939
* @param byteArray internal byte array
4040
* @param byteOrder the internal byte order - this is used to interpret given array, not to change it

src/test/java/at/favre/lib/bytes/ABytesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import static org.junit.Assert.*;
2929

30-
abstract class ABytesTest {
30+
public abstract class ABytesTest {
3131
byte[] example_bytes_empty;
3232

3333
byte[] example_bytes_one;

src/test/java/at/favre/lib/bytes/MutableBytesTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public void setByteAtTest() {
106106

107107
for (int i = 0; i < b.length(); i++) {
108108
byte old = b.byteAt(i);
109-
b.setByteAt(i, (byte) 0);
109+
MutableBytes bcopy = b.setByteAt(i, (byte) 0);
110+
assertSame(b, bcopy);
110111
if (old != 0) {
111112
assertNotEquals(old, b.byteAt(i));
112113
}

0 commit comments

Comments
 (0)