|
4 | 4 | import java.util.Map; |
5 | 5 |
|
6 | 6 | /** |
7 | | - * A thread-safe, versioned store for {@link FeatureFlag} objects. |
8 | | - * Implementations should permit concurrent access and updates. |
9 | | - * |
| 7 | + * A thread-safe, versioned store for feature flags and related objects received from the |
| 8 | + * streaming API. Implementations should permit concurrent access and updates. |
| 9 | + * <p> |
10 | 10 | * Delete and upsert requests are versioned-- if the version number in the request is less than |
11 | | - * the currently stored version of the feature, the request should be ignored. |
12 | | - * |
| 11 | + * the currently stored version of the object, the request should be ignored. |
| 12 | + * <p> |
13 | 13 | * These semantics support the primary use case for the store, which synchronizes a collection |
14 | | - * of features based on update messages that may be received out-of-order. |
15 | | - * |
| 14 | + * of objects based on update messages that may be received out-of-order. |
| 15 | + * @since 3.0.0 |
16 | 16 | */ |
17 | 17 | public interface FeatureStore extends Closeable { |
18 | 18 | /** |
19 | | - * |
20 | | - * Returns the {@link FeatureFlag} to which the specified key is mapped, or |
21 | | - * null if the key is not associated or the associated {@link FeatureFlag} has |
| 19 | + * Returns the object to which the specified key is mapped, or |
| 20 | + * null if the key is not associated or the associated object has |
22 | 21 | * been deleted. |
23 | 22 | * |
24 | | - * @param key the key whose associated {@link FeatureFlag} is to be returned |
25 | | - * @return the {@link FeatureFlag} to which the specified key is mapped, or |
26 | | - * null if the key is not associated or the associated {@link FeatureFlag} has |
| 23 | + * @param <T> class of the object that will be returned |
| 24 | + * @param kind the kind of object to get |
| 25 | + * @param key the key whose associated object is to be returned |
| 26 | + * @return the object to which the specified key is mapped, or |
| 27 | + * null if the key is not associated or the associated object has |
27 | 28 | * been deleted. |
28 | 29 | */ |
29 | | - FeatureFlag get(String key); |
| 30 | + <T extends VersionedData> T get(VersionedDataKind<T> kind, String key); |
30 | 31 |
|
31 | 32 | /** |
32 | | - * Returns a {@link java.util.Map} of all associated features. |
33 | | - * |
| 33 | + * Returns a {@link java.util.Map} of all associated objects of a given kind. |
34 | 34 | * |
35 | | - * @return a map of all associated features. |
| 35 | + * @param <T> class of the objects that will be returned in the map |
| 36 | + * @param kind the kind of objects to get |
| 37 | + * @return a map of all associated object. |
36 | 38 | */ |
37 | | - Map<String, FeatureFlag> all(); |
| 39 | + <T extends VersionedData> Map<String, T> all(VersionedDataKind<T> kind); |
38 | 40 |
|
39 | 41 | /** |
40 | | - * Initializes (or re-initializes) the store with the specified set of features. Any existing entries |
41 | | - * will be removed. Implementations can assume that this set of features is up to date-- there is no |
42 | | - * need to perform individual version comparisons between the existing features and the supplied |
| 42 | + * Initializes (or re-initializes) the store with the specified set of objects. Any existing entries |
| 43 | + * will be removed. Implementations can assume that this set of objects is up to date-- there is no |
| 44 | + * need to perform individual version comparisons between the existing objects and the supplied |
43 | 45 | * features. |
44 | 46 | * |
45 | | - * |
46 | | - * @param features the features to set the store |
| 47 | + * @param allData all objects to be stored |
47 | 48 | */ |
48 | | - void init(Map<String, FeatureFlag> features); |
| 49 | + void init(Map<VersionedDataKind<?>, Map<String, ? extends VersionedData>> allData); |
49 | 50 |
|
50 | 51 | /** |
51 | | - * |
52 | | - * Deletes the feature associated with the specified key, if it exists and its version |
| 52 | + * Deletes the object associated with the specified key, if it exists and its version |
53 | 53 | * is less than or equal to the specified version. |
54 | 54 | * |
55 | | - * @param key the key of the feature to be deleted |
| 55 | + * @param <T> class of the object to be deleted |
| 56 | + * @param kind the kind of object to delete |
| 57 | + * @param key the key of the object to be deleted |
56 | 58 | * @param version the version for the delete operation |
57 | 59 | */ |
58 | | - void delete(String key, int version); |
| 60 | + <T extends VersionedData> void delete(VersionedDataKind<T> kind, String key, int version); |
59 | 61 |
|
60 | 62 | /** |
61 | | - * Update or insert the feature associated with the specified key, if its version |
62 | | - * is less than or equal to the version specified in the argument feature. |
| 63 | + * Update or insert the object associated with the specified key, if its version |
| 64 | + * is less than or equal to the version specified in the argument object. |
63 | 65 | * |
64 | | - * @param key |
65 | | - * @param feature |
| 66 | + * @param <T> class of the object to be updated |
| 67 | + * @param kind the kind of object to update |
| 68 | + * @param item the object to update or insert |
66 | 69 | */ |
67 | | - void upsert(String key, FeatureFlag feature); |
| 70 | + <T extends VersionedData> void upsert(VersionedDataKind<T> kind, T item); |
68 | 71 |
|
69 | 72 | /** |
70 | | - * Returns true if this store has been initialized |
| 73 | + * Returns true if this store has been initialized. |
71 | 74 | * |
72 | 75 | * @return true if this store has been initialized |
73 | 76 | */ |
|
0 commit comments