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.
  • Field Details

  • Constructor Details

    • ByteArrayPortability

      protected ByteArrayPortability()
  • Method Details

    • 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 to
      readBuffer - buffer containing encoded object
      Returns:
      true if the two parameters are "equal"
      Throws:
      UnsupportedOperationException