View Javadoc
1   package com.github.celldynamics.quimp.filesystem;
2   
3   import java.lang.reflect.Type;
4   
5   import com.github.celldynamics.quimp.ViewUpdater;
6   import com.github.celldynamics.quimp.plugin.engine.PluginFactory;
7   import com.google.gson.Gson;
8   import com.google.gson.InstanceCreator;
9   
10  /**
11   * Object builder for GSon and DataContainer class.
12   * 
13   * <p>This class is used on load JSon representation of DataContainer class. Rebuilds
14   * snakePluginList
15   * field that is not serialized. This field keeps current state of plugins.
16   * 
17   * @author p.baniukiewicz
18   * @see Gson
19   */
20  public class DataContainerInstanceCreator implements InstanceCreator<DataContainer> {
21  
22    private PluginFactory pf;
23    private ViewUpdater vu;
24  
25    /**
26     * Assign additional fields to DataContainer after serialization.
27     * 
28     * @param pf PluginFactory
29     * @param vu ViewUpdater
30     */
31    public DataContainerInstanceCreator(final PluginFactory pf, final ViewUpdater vu) {
32      this.pf = pf;
33      this.vu = vu;
34    }
35  
36    /*
37     * (non-Javadoc)
38     * 
39     * @see com.google.gson.InstanceCreator#createInstance(java.lang.reflect.Type)
40     */
41    @Override
42    public DataContainer createInstance(Type arg0) {
43      DataContainerp/filesystem/DataContainer.html#DataContainer">DataContainer dt = new DataContainer(pf, vu);
44      return dt;
45    }
46  }