All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.commons.marshall.IdentityMarshaller Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.commons.marshall;

import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_UNKNOWN;

import org.infinispan.commons.dataconversion.MediaType;
import org.infinispan.commons.io.ByteBuffer;
import org.infinispan.commons.io.ByteBufferImpl;

/**
 * A marshaller that does not transform the content, only applicable to byte[] payloads.
 *
 * @since 9.3
 */
public class IdentityMarshaller extends AbstractMarshaller {

   public static final IdentityMarshaller INSTANCE = new IdentityMarshaller();

   @Override
   protected ByteBuffer objectToBuffer(Object o, int estimatedSize) {
      return ByteBufferImpl.create((byte[]) o);
   }

   @Override
   public Object objectFromByteBuffer(byte[] buf, int offset, int length) {
      return buf;
   }

   @Override
   public boolean isMarshallable(Object o) {
      return o instanceof byte[];
   }

   @Override
   public MediaType mediaType() {
      return APPLICATION_UNKNOWN;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy