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

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

There is a newer version: 15.1.0.Dev04
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 java.util.function.Supplier;

import org.infinispan.commons.util.Util;

public class SuppliedExternalizer implements AdvancedExternalizer {
   private final Integer id;
   private final Class clazz;
   private final Supplier supplier;

   public SuppliedExternalizer(Integer id, Class clazz, Supplier supplier) {
      this.id = id;
      this.clazz = clazz;
      this.supplier = supplier;
   }

   @Override
   public Set> getTypeClasses() {
      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 supplier.get();
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy