org.terracotta.offheapstore.storage.portability
Class ByteArrayPortability
java.lang.Object
org.terracotta.offheapstore.storage.portability.ByteArrayPortability
- All Implemented Interfaces:
- Portability<byte[]>
- Direct Known Subclasses:
- PersistentByteArrayPortability
public class ByteArrayPortability
- extends Object
- implements Portability<byte[]>
A simple byte[] portability.
- Author:
- Chris Dennis
|
Method Summary |
byte[] |
decode(ByteBuffer buffer)
Decodes a ByteBuffer to an object of type T. |
ByteBuffer |
encode(byte[] object)
Encodes an object of type T as a ByteBuffer. |
boolean |
equals(Object value,
ByteBuffer readBuffer)
Byte arrays do not have a content-based equals method so this throws
UnsupportedOperationException. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INSTANCE
public static final ByteArrayPortability INSTANCE
ByteArrayPortability
protected ByteArrayPortability()
encode
public ByteBuffer encode(byte[] object)
- Description copied from interface:
Portability
- Encodes an object of type
T as a ByteBuffer.
- Specified by:
encode in interface Portability<byte[]>
- Parameters:
object - object to be encoded
- Returns:
- the encoded object
decode
public byte[] decode(ByteBuffer buffer)
- Description copied from interface:
Portability
- Decodes a
ByteBuffer to an object of type T.
- Specified by:
decode in interface Portability<byte[]>
- Parameters:
buffer - bytes to decode
- Returns:
- the decoded object
equals
public boolean equals(Object value,
ByteBuffer readBuffer)
throws UnsupportedOperationException
- Byte arrays do not have a content-based equals method so this throws
UnsupportedOperationException.
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:
equals in interface Portability<byte[]>
- Parameters:
value - object to compare toreadBuffer - buffer containing encoded object
- Returns:
true if the two parameters are "equal"
- Throws:
UnsupportedOperationException
Copyright © 2016. All Rights Reserved.