Class MarshallableObject<T>

java.lang.Object
org.infinispan.marshall.protostream.impl.MarshallableObject<T>

@ProtoTypeId(22) public class MarshallableObject<T> extends Object
A wrapper for interface implementations which can either be marshalled by the GlobalMarshaller or the configured user marshaller if no internal marshaller exists for the implementation. In such scenarios it's not possible to use WrappedMessage as it will ignore any configured user marshaller, and similarly, it's not possible to use MarshallableUserObject as that exclusively utilises the user marshaller.

A good example of when this class is required, is for the marshalling of Metadata implementations. We utilise many internal implementations, which always have a ProtoStream marshaller available; however, it's also possible for users to provide custom implementations which must be handled by the configured user marshaller.

Since:
16.0
Author:
Ryan Emerson
  • Field Details

    • object

      protected final T object
  • Constructor Details

    • MarshallableObject

      public MarshallableObject(T object)
  • Method Details

    • create

      public static <T> MarshallableObject<T> create(T object)
      Parameters:
      object - the Object to be wrapped.
      Returns:
      a new MarshallableObject instance containing the passed object if the object is not null, otherwise null.
    • unwrap

      public static <T> T unwrap(MarshallableObject<T> wrapper)
      Parameters:
      wrapper - the MarshallableObject instance to unwrap.
      Returns:
      the wrapped Object or null if the provided wrapper does not exist.
    • get

      public T get()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public static int size(int objectBytes)
    • toString

      public String toString()
      Overrides:
      toString in class Object