Class ByteBufferMarshalledValue<V>

java.lang.Object
org.wildfly.clustering.marshalling.ByteBufferMarshalledValue<V>
Type Parameters:
V - the type wrapped by this marshalled value
All Implemented Interfaces:
Serializable, MarshalledValue<V, ByteBufferMarshaller>
Direct Known Subclasses:
ByteBufferMarshalledKey

public class ByteBufferMarshalledValue<V> extends Object implements MarshalledValue<V, ByteBufferMarshaller>, Serializable
MarshalledValue implementation that uses a ByteBufferMarshaller.
Author:
Paul Ferraro
See Also:
  • Constructor Details

    • ByteBufferMarshalledValue

      public ByteBufferMarshalledValue(V object, ByteBufferMarshaller marshaller)
      Constructs a marshalled value from the specified object and marshaller.
      Parameters:
      object - the wrapped object
      marshaller - a marshaller suitable for marshalling the specified object
    • ByteBufferMarshalledValue

      public ByteBufferMarshalledValue(ByteBuffer buffer)
      Constructs a marshalled value from the specified byte buffer. This constructor is only public to facilitate marshallers of this object (from other packages). The byte buffer parameter must not be read outside the context of this object.
      Parameters:
      buffer - a byte buffer
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Indicates whether or not this value is empty.
      Returns:
      true, if this value is empty, false otherwise
    • getBuffer

      public ByteBuffer getBuffer() throws IOException
      Returns the byte buffer of this value, marshalling it if necessary.
      Returns:
      the byte buffer of this value.
      Throws:
      IOException - if the value could not be marshalled
    • size

      public OptionalInt size()
      If present, returns the size of the buffer returned by getBuffer().
      Returns:
      an optional buffer size
    • get

      public V get(ByteBufferMarshaller marshaller) throws IOException
      Description copied from interface: MarshalledValue
      Returns the value, unmarshalling using the specified context if necessary.
      Specified by:
      get in interface MarshalledValue<V, ByteBufferMarshaller>
      Parameters:
      marshaller - a marshalling context
      Returns:
      the value wrapped by this marshalled value.
      Throws:
      IOException - if the value could not be unmarshalled.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object