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

org.infinispan.commons.dataconversion.ByteArrayWrapper Maven / Gradle / Ivy

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

import org.infinispan.commons.marshall.WrappedByteArray;

/**
 * Wraps byte[] on a {@link WrappedByteArray} to provide equality and hashCode support, leaving other objects
 * unchanged.
 *
 * @since 9.1
 */
public class ByteArrayWrapper implements Wrapper {

   public static final ByteArrayWrapper INSTANCE = new ByteArrayWrapper();

   @Override
   public Object wrap(Object obj) {
      if (obj instanceof byte[]) return new WrappedByteArray((byte[]) obj);
      return obj;
   }

   @Override
   public Object unwrap(Object obj) {
      if (obj != null && obj.getClass() == WrappedByteArray.class)
         return WrappedByteArray.class.cast(obj).getBytes();
      return obj;
   }

   @Override
   public byte id() {
      return WrapperIds.BYTE_ARRAY_WRAPPER;
   }

   @Override
   public boolean isFilterable() {
      return false;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy