Interface Marshaller<T,R>

Type Parameters:
T - The object (T)ype.
R - The (R)aw type, for example, byte[].
All Known Subinterfaces:
ByteArrayMarshaller<T>

public interface Marshaller<T,R>
Object marshaller interface that is used in every Ignite API that requires serialization/deserialization of user objects. If you want to define the way your objects are serialized/deserialized, you can implement this interface and pass it to the API that requires it.

NOTE: The marshaller itself are not sent over the wire. This means that if you define a custom marshaller on the client, you must also define the marshaller on the server as well.

  • Method Summary

    Modifier and Type
    Method
    Description
    marshal(T object)
    Marshal the object into raw type.
    static <T, R> R
    tryMarshalOrCast(@Nullable Marshaller<T,R> self, @Nullable Object object)
    Try to marshal given object if marshaller if not null, else the object is casted directly to the target type.
    static <T, R> T
    tryUnmarshalOrCast(@Nullable Marshaller<T,R> self, @Nullable Object raw)
    Try to unmarshal given object if marshaller if not null, else the object is casted directly to the target type.
    unmarshal(R raw)
    Unmarshal the raw type into object.
  • Method Details

    • marshal

      @Nullable R marshal(@Nullable T object) throws UnsupportedObjectTypeMarshallingException
      Marshal the object into raw type.
      Parameters:
      object - object to marshal.
      Returns:
      raw presentation of object.
      Throws:
      UnsupportedObjectTypeMarshallingException - if the given type can not be marshalled with current instance.
    • unmarshal

      @Nullable T unmarshal(@Nullable R raw) throws UnsupportedObjectTypeMarshallingException
      Unmarshal the raw type into object.
      Parameters:
      raw - raw presentation of object.
      Returns:
      object.
      Throws:
      UnsupportedObjectTypeMarshallingException - if the given type can not be unmarshalled with current instance.
    • tryMarshalOrCast

      @Nullable static <T, R> R tryMarshalOrCast(@Nullable @Nullable Marshaller<T,R> self, @Nullable @Nullable Object object)
      Try to marshal given object if marshaller if not null, else the object is casted directly to the target type.
      Type Parameters:
      T - The object (T)ype.
      R - The (R)aw type, for example.
      Parameters:
      self - the marshaller instance.
      object - to marshal.
    • tryUnmarshalOrCast

      @Nullable static <T, R> T tryUnmarshalOrCast(@Nullable @Nullable Marshaller<T,R> self, @Nullable @Nullable Object raw)
      Try to unmarshal given object if marshaller if not null, else the object is casted directly to the target type.
      Type Parameters:
      T - The object (T)ype.
      R - The (R)aw type, for example, byte[].
      Parameters:
      self - the marshaller instance.