Package org.infinispan.commons.marshall
Class WrappedByteArray
- java.lang.Object
-
- org.infinispan.commons.marshall.WrappedByteArray
-
- All Implemented Interfaces:
WrappedBytes
public class WrappedByteArray extends Object implements WrappedBytes
Simple wrapper around a byte[] to provide equals and hashCode semantics- Since:
- 9.0
- Author:
- wburns
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWrappedByteArray.Externalizer
-
Field Summary
Fields Modifier and Type Field Description static WrappedByteArrayEMPTY_BYTES
-
Constructor Summary
Constructors Constructor Description WrappedByteArray(byte[] bytes)WrappedByteArray(byte[] bytes, int hashCode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbackArrayOffset()The offset of where data starts in the backed array.booleanequals(Object o)booleanequalsWrappedBytes(WrappedBytes other)bytegetByte(int offset)Retrieves the byte given an offset.byte[]getBytes()The backing array if there is one otherwise null is returned.intgetLength()The length of the underlying wrapped bytes.inthashCode()StringtoString()
-
-
-
Field Detail
-
EMPTY_BYTES
public static final WrappedByteArray EMPTY_BYTES
-
-
Method Detail
-
getBytes
public byte[] getBytes()
Description copied from interface:WrappedBytesThe backing array if there is one otherwise null is returned. Callers should useWrappedBytes.backArrayOffset()to know where to read the bytes from. This byte[] should never be modified by the caller- Specified by:
getBytesin interfaceWrappedBytes- Returns:
- the backing byte[] if there is one.
-
backArrayOffset
public int backArrayOffset()
Description copied from interface:WrappedBytesThe offset of where data starts in the backed array.- Specified by:
backArrayOffsetin interfaceWrappedBytes- Returns:
- -1 if there is no backed array otherwise ≥ 0 if there is backing array
-
getLength
public int getLength()
Description copied from interface:WrappedBytesThe length of the underlying wrapped bytes. This will always be ≥ 0.- Specified by:
getLengthin interfaceWrappedBytes- Returns:
- how many bytes are available from the underlying wrapped implementation
-
getByte
public byte getByte(int offset)
Description copied from interface:WrappedBytesRetrieves the byte given an offset. This offset should always be less thanWrappedBytes.getLength().- Specified by:
getBytein interfaceWrappedBytes- Parameters:
offset- the offset of where to find the byte- Returns:
- the byte at this position
-
equalsWrappedBytes
public boolean equalsWrappedBytes(WrappedBytes other)
- Specified by:
equalsWrappedBytesin interfaceWrappedBytes
-
-