public class OpaqueBytes extends ByteSequence
A simple class that wraps a byte array and makes the equals/hashCode/toString methods work as you actually expect. In an ideal JVM this would be a value type and be completely overhead free. Project Valhalla is adding such functionality to Java, but it won't arrive for a few years yet!
Modifier and Type | Class and Description |
---|---|
static class |
OpaqueBytes.Companion |
Modifier and Type | Field and Description |
---|---|
static OpaqueBytes.Companion |
Companion |
Constructor and Description |
---|
OpaqueBytes(byte[] bytes)
A simple class that wraps a byte array and makes the equals/hashCode/toString methods work as you actually expect.
In an ideal JVM this would be a value type and be completely overhead free. Project Valhalla is adding such
functionality to Java, but it won't arrive for a few years yet!
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes()
The bytes are always cloned so that this object becomes immutable. This has been done
to prevent tampering with entities such as
class SecureHash and class PrivacySalt , as well as
preserve the integrity of our hash constants SecureHash.Companion.getZeroHash and SecureHash.Companion.getAllOnesHash . |
public static OpaqueBytes.Companion Companion
public OpaqueBytes(byte[] bytes)
A simple class that wraps a byte array and makes the equals/hashCode/toString methods work as you actually expect. In an ideal JVM this would be a value type and be completely overhead free. Project Valhalla is adding such functionality to Java, but it won't arrive for a few years yet!
public byte[] getBytes()
The bytes are always cloned so that this object becomes immutable. This has been done
to prevent tampering with entities such as class SecureHash
and class PrivacySalt
, as well as
preserve the integrity of our hash constants SecureHash.Companion.getZeroHash
and SecureHash.Companion.getAllOnesHash
.
Cloning like this may become a performance issue, depending on whether or not the JIT compiler is ever able to optimise away the clone. In which case we may need to revisit this later.