|
| 1 | +package io.ably.lib.objects; |
| 2 | + |
| 3 | +import io.ably.lib.objects.batch.BatchContextBuilder; |
| 4 | +import io.ably.lib.types.Callback; |
| 5 | + |
| 6 | +import java.util.Map; |
| 7 | + |
| 8 | +/** |
| 9 | + * The LiveObjects interface provides methods to interact with live data objects, |
| 10 | + * such as maps and counters, in a real-time environment. It supports both synchronous |
| 11 | + * and asynchronous operations for retrieving and creating live objects. |
| 12 | + */ |
| 13 | +public interface LiveObjects { |
| 14 | + |
| 15 | + /** |
| 16 | + * Retrieves the root LiveMap object. |
| 17 | + * |
| 18 | + * @return the root LiveMap instance. |
| 19 | + */ |
| 20 | + LiveMap getRoot(); |
| 21 | + |
| 22 | + /** |
| 23 | + * Initiates a batch operation and provides a BatchContext through a callback. |
| 24 | + * |
| 25 | + * @param batchContextCallback the callback to handle the BatchContext or error. |
| 26 | + */ |
| 27 | + void batch(BatchContextBuilder batchContextCallback); |
| 28 | + |
| 29 | + /** |
| 30 | + * Creates a new LiveMap based on an existing LiveMap. |
| 31 | + * |
| 32 | + * @param liveMap the existing LiveMap to base the new LiveMap on. |
| 33 | + * @return the newly created LiveMap instance. |
| 34 | + */ |
| 35 | + LiveMap createMap(LiveMap liveMap); |
| 36 | + |
| 37 | + /** |
| 38 | + * Creates a new LiveMap based on a LiveCounter. |
| 39 | + * |
| 40 | + * @param liveCounter the LiveCounter to base the new LiveMap on. |
| 41 | + * @return the newly created LiveMap instance. |
| 42 | + */ |
| 43 | + LiveMap createMap(LiveCounter liveCounter); |
| 44 | + |
| 45 | + /** |
| 46 | + * Creates a new LiveMap based on a standard Java Map. |
| 47 | + * |
| 48 | + * @param map the Java Map to base the new LiveMap on. |
| 49 | + * @return the newly created LiveMap instance. |
| 50 | + */ |
| 51 | + LiveMap createMap(Map<String, Object> map); |
| 52 | + |
| 53 | + /** |
| 54 | + * Creates a new LiveCounter with an initial value. |
| 55 | + * |
| 56 | + * @param initialValue the initial value of the LiveCounter. |
| 57 | + * @return the newly created LiveCounter instance. |
| 58 | + */ |
| 59 | + LiveCounter createCounter(Long initialValue); |
| 60 | + |
| 61 | + /** |
| 62 | + * Asynchronously retrieves the root LiveMap object. |
| 63 | + * |
| 64 | + * @param callback the callback to handle the result or error. |
| 65 | + */ |
| 66 | + void getRootAsync(Callback<LiveMap> callback); |
| 67 | + |
| 68 | + /** |
| 69 | + * Initiates a batch operation asynchronously. |
| 70 | + * |
| 71 | + * @param batchContextCallback the BatchContextBuilder to build the BatchContext. |
| 72 | + * @param callback the Callback to handle the completion or error of the batch operation. |
| 73 | + */ |
| 74 | + void batchAsync(BatchContextBuilder batchContextCallback, Callback<Void> callback); |
| 75 | + |
| 76 | + /** |
| 77 | + * Asynchronously creates a new LiveMap based on an existing LiveMap. |
| 78 | + * |
| 79 | + * @param liveMap the existing LiveMap to base the new LiveMap on. |
| 80 | + * @param callback the callback to handle the result or error. |
| 81 | + */ |
| 82 | + void createMapAsync(LiveMap liveMap, Callback<LiveMap> callback); |
| 83 | + |
| 84 | + /** |
| 85 | + * Asynchronously creates a new LiveMap based on a LiveCounter. |
| 86 | + * |
| 87 | + * @param liveCounter the LiveCounter to base the new LiveMap on. |
| 88 | + * @param callback the callback to handle the result or error. |
| 89 | + */ |
| 90 | + void createMapAsync(LiveCounter liveCounter, Callback<LiveMap> callback); |
| 91 | + |
| 92 | + /** |
| 93 | + * Asynchronously creates a new LiveMap based on a standard Java Map. |
| 94 | + * |
| 95 | + * @param map the Java Map to base the new LiveMap on. |
| 96 | + * @param callback the callback to handle the result or error. |
| 97 | + */ |
| 98 | + void createMapAsync(Map<String, Object> map, Callback<LiveMap> callback); |
| 99 | + |
| 100 | + /** |
| 101 | + * Asynchronously creates a new LiveCounter with an initial value. |
| 102 | + * |
| 103 | + * @param initialValue the initial value of the LiveCounter. |
| 104 | + * @param callback the callback to handle the result or error. |
| 105 | + */ |
| 106 | + void createCounterAsync(Long initialValue, Callback<LiveCounter> callback); |
| 107 | +} |
0 commit comments