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

org.infinispan.spring.provider.NullValue Maven / Gradle / Ivy

There is a newer version: 10.0.0.Alpha1
Show newest version
package org.infinispan.spring.provider;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;

import org.infinispan.commons.marshall.SerializeWith;
import org.springframework.cache.Cache.ValueWrapper;

/**
 * A placeholder value for storing {@literal null} in a cache.
 *
 * @author Olaf Bergner
 * @since 5.3
 */
@SerializeWith(NullValue.Externalizer.class)
final class NullValue implements ValueWrapper, Serializable {

   /** The serialVersionUID */
   private static final long serialVersionUID = 6104836300055942197L;

   static final NullValue NULL = new NullValue();

   /**
    * Always returns {@literal null}.
    *
    * @return {@literal null}
    * @see org.springframework.cache.Cache.ValueWrapper#get()
    */
   @Override
   public Object get() {
      return null;
   }

   /**
    * Create a new NullValue.
    *
    */
   private NullValue() {
      // Intentionally left blank
   }

   public static class Externalizer implements org.infinispan.commons.marshall.Externalizer, Serializable {

      /** The serialVersionUID */
      private static final long serialVersionUID = -6374308529927819177L;

      /**
       * @param output
       * @param object
       * @throws IOException
       * @see org.infinispan.commons.marshall.Externalizer#writeObject(java.io.ObjectOutput,
       *      java.lang.Object)
       */
      @Override
      public void writeObject(ObjectOutput output, NullValue object) throws IOException {
         // Nothing to do?
      }

      /**
       * @param input
       * @return
       * @throws IOException
       * @throws ClassNotFoundException
       * @see org.infinispan.commons.marshall.Externalizer#readObject(java.io.ObjectInput)
       */
      @Override
      public NullValue readObject(ObjectInput input) throws IOException, ClassNotFoundException {
         return NullValue.NULL;
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy