tom | 0755a36 | 2014-09-24 11:54:43 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.store; |
| 2 | |
| 3 | import org.onlab.onos.event.Event; |
| 4 | |
| 5 | /** |
| 6 | * Base implementation of a store. |
| 7 | */ |
| 8 | public class AbstractStore<E extends Event, D extends StoreDelegate<E>> |
| 9 | implements Store<E, D> { |
| 10 | |
| 11 | protected D delegate; |
| 12 | |
| 13 | @Override |
| 14 | public void setDelegate(D delegate) { |
| 15 | this.delegate = delegate; |
| 16 | } |
| 17 | |
| 18 | @Override |
| 19 | public D getDelegate() { |
| 20 | return delegate; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Notifies the delegate with the specified event. |
| 25 | * |
| 26 | * @param event event to delegate |
| 27 | */ |
| 28 | protected void notifyDelegate(E event) { |
| 29 | if (delegate != null) { |
| 30 | delegate.notify(event); |
| 31 | } |
| 32 | } |
| 33 | } |