BUG-6650: ep-ip/sgt, propose sxp-generator
[groupbasedpolicy.git] / sxp-integration / sxp-ep-provider / src / main / java / org / opendaylight / groupbasedpolicy / sxp / ep / provider / impl / SimpleCachedDao.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.groupbasedpolicy.sxp.ep.provider.impl;
10
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13
14 /**
15  * Purpose: encapsulate access to DS by exposing
16  * <dl>
17  * <dt>find</dt>
18  * <dd>search through cached values</dd>
19  * <dt>update</dt>
20  * <dd>stores given pair (key, value) to local cache</dd>
21  * </dl>
22  *
23  * @param <K> data key type
24  * @param <V> data type
25  */
26 public interface SimpleCachedDao<K, V> extends SimpleDao<K, V> {
27
28     /**
29      * store given pair to local cache
30      *
31      * @param key   associated to value
32      * @param value associated to key
33      */
34     V update(@Nonnull K key, @Nullable V value);
35
36     /**
37      * invalidate all cache entries
38      */
39     void invalidateCache();
40
41     /**
42      * @return true if there is nothing cached
43      */
44     boolean isEmpty();
45
46     /**
47      * @return unmodifiable iterator through all cached values
48      */
49     Iterable<V> values();
50
51     /**
52      * @return unmodifiable iterator through all cached keys
53      */
54     Iterable<K> keySet();
55 }