View Javadoc
1   package com.github.davidmoten.rx2.buffertofile;
2   
3   import java.io.IOException;
4   
5   public interface Serializer<T> {
6   
7       /**
8        * Returns a byte array of length &gt; 0 that is the serialization of the
9        * given value. Note that there are performance advantages if you ensure
10       * that the byte array produced has a length that is a multiple of four.
11       * 
12       * @param t
13       *            value to be serialized into a byte array, should not be null.
14       * @return a byte array of length &gt; 0
15       * @throws IOException
16       *             on error
17       */
18      byte[] serialize(T t) throws IOException;
19  
20      /**
21       * Returns a non-null instance of T from the byte array of length &gt; 0.
22       * 
23       * @param bytes
24       *            byte array, should have length &gt; 0
25       * @return instance of T
26       * @throws IOException
27       *             on error
28       * @throws ClassNotFoundException
29       *             if class T not found
30       */
31      T deserialize(byte[] bytes) throws IOException, ClassNotFoundException;
32  }