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

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

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

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Set;

import org.infinispan.commons.util.Util;

public class SingletonExternalizer implements AdvancedExternalizer {
   private final Integer id;
   private final T instance;

   public SingletonExternalizer(Integer id, T instance) {
      this.id = id;
      this.instance = instance;
   }

   @Override
   public Set> getTypeClasses() {
      Class clazz = (Class) instance.getClass();
      return Util.asSet(clazz);
   }

   @Override
   public Integer getId() {
      return id;
   }

   @Override
   public void writeObject(ObjectOutput output, T object) throws IOException {
   }

   @Override
   public T readObject(ObjectInput input) throws IOException, ClassNotFoundException {
      return instance;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy