1   package eu.fbk.knowledgestore.datastore;
2   
3   import java.io.IOException;
4   
5   import com.google.common.collect.ForwardingObject;
6   
7   /**
8    * A {@code DataStore} forwarding all its method calls to another {@code DataStore}.
9    * <p>
10   * This class provides a starting point for implementing the decorator pattern on top of the
11   * {@code DataStore} interface. Subclasses must implement method {@link #delegate()} and override
12   * the methods of {@code DataStore} they want to decorate.
13   * </p>
14   */
15  public abstract class ForwardingDataStore extends ForwardingObject implements DataStore {
16  
17      @Override
18      protected abstract DataStore delegate();
19  
20      @Override
21      public void init() throws IOException {
22          delegate().init();
23      }
24  
25      @Override
26      public DataTransaction begin(final boolean readOnly) throws IOException, IllegalStateException {
27          return delegate().begin(readOnly);
28      }
29  
30      @Override
31      public void close() {
32          delegate().close();
33      }
34  
35  }