Class ByteArrayPortability
- java.lang.Object
-
- org.terracotta.offheapstore.storage.portability.ByteArrayPortability
-
- All Implemented Interfaces:
Portability<byte[]>
- Direct Known Subclasses:
PersistentByteArrayPortability
public class ByteArrayPortability extends java.lang.Object implements Portability<byte[]>
A simplebyte[]portability.
-
-
Field Summary
Fields Modifier and Type Field Description static ByteArrayPortabilityINSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description protectedByteArrayPortability()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decode(java.nio.ByteBuffer buffer)Decodes aByteBufferto an object of typeT.java.nio.ByteBufferencode(byte[] object)Encodes an object of typeTas aByteBuffer.booleanequals(java.lang.Object value, java.nio.ByteBuffer readBuffer)Byte arrays do not have a content-based equals method so this throwsUnsupportedOperationException.
-
-
-
Field Detail
-
INSTANCE
public static final ByteArrayPortability INSTANCE
-
-
Method Detail
-
encode
public java.nio.ByteBuffer encode(byte[] object)
Description copied from interface:PortabilityEncodes an object of typeTas aByteBuffer.- Specified by:
encodein interfacePortability<byte[]>- Parameters:
object- object to be encoded- Returns:
- the encoded object
-
decode
public byte[] decode(java.nio.ByteBuffer buffer)
Description copied from interface:PortabilityDecodes aByteBufferto an object of typeT.- Specified by:
decodein interfacePortability<byte[]>- Parameters:
buffer- bytes to decode- Returns:
- the decoded object
-
equals
public boolean equals(java.lang.Object value, java.nio.ByteBuffer readBuffer) throws java.lang.UnsupportedOperationExceptionByte arrays do not have a content-based equals method so this throwsUnsupportedOperationException.The lack of any implementation only prevents this portability being used as a key portability. Using byte arrays as keys in map would be extremely questionable in any case. If necessary this portability could be sub-classed to do deep array comparison.
- Specified by:
equalsin interfacePortability<byte[]>- Parameters:
value- object to compare toreadBuffer- buffer containing encoded object- Returns:
trueif the two parameters are "equal"- Throws:
java.lang.UnsupportedOperationException
-
-