|
21 | 21 | import java.util.Map; |
22 | 22 |
|
23 | 23 | /** |
24 | | - * A template layer to Hazelcast key-value type |
| 24 | + * A specialized {@link KeyValueTemplate} for Hazelcast, |
| 25 | + * providing methods to execute queries using SQL-like expressions and predicates. |
| 26 | + * <p> |
| 27 | + * This template facilitates querying key-value structures stored in a Hazelcast instance. |
| 28 | + * It supports both SQL-like queries with named parameters and Hazelcast-specific predicates. |
| 29 | + * </p> |
| 30 | + * |
| 31 | + * Example usage: |
| 32 | + * <pre> |
| 33 | + * {@code |
| 34 | + * @Inject |
| 35 | + * private HazelcastTemplate hazelcastTemplate; |
| 36 | + * |
| 37 | + * // Query using SQL-like syntax |
| 38 | + * Collection<Movie> movies = hazelcastTemplate.sql("name = :name", Map.of("name", "Inception")); |
| 39 | + * movies.forEach(System.out::println); |
| 40 | + * |
| 41 | + * // Query using Hazelcast Predicate |
| 42 | + * Predicate<String, Movie> predicate = Predicates.equal("genre", "Sci-Fi"); |
| 43 | + * Collection<Movie> sciFiMovies = hazelcastTemplate.sql(predicate); |
| 44 | + * sciFiMovies.forEach(System.out::println); |
| 45 | + * } |
| 46 | + * </pre> |
| 47 | + * |
| 48 | + * @see KeyValueTemplate |
25 | 49 | */ |
26 | 50 | public interface HazelcastTemplate extends KeyValueTemplate { |
27 | 51 |
|
28 | 52 | /** |
29 | | - * Executes hazelcast query |
| 53 | + * Executes a Hazelcast query using SQL-like syntax. |
| 54 | + * <p> |
| 55 | + * The query should follow Hazelcast's SQL-like query syntax for key-value stores. |
| 56 | + * </p> |
30 | 57 | * |
31 | 58 | * @param <T> the entity type |
32 | | - * @param query the query |
33 | | - * @return the result query |
34 | | - * @throws NullPointerException when there is null query |
| 59 | + * @param query the SQL-like query string |
| 60 | + * @return a collection of matching entities |
| 61 | + * @throws NullPointerException if the query is null |
35 | 62 | */ |
36 | 63 | <T> Collection<T> sql(String query); |
37 | 64 |
|
38 | 65 | /** |
39 | | - * Executes hazelcast query with named query. |
40 | | - * E.g.: bucketManager.query("name = :name", singletonMap("name", "Matrix")) |
| 66 | + * Executes a Hazelcast query with named parameters. |
| 67 | + * <p> |
| 68 | + * Example usage: |
| 69 | + * <pre> |
| 70 | + * {@code |
| 71 | + * Collection<Movie> movies = hazelcastTemplate.sql("name = :name", Map.of("name", "The Matrix")); |
| 72 | + * } |
| 73 | + * </pre> |
| 74 | + * </p> |
41 | 75 | * |
42 | | - * @param query the query |
43 | 76 | * @param <T> the entity type |
44 | | - * @param params the params to bind |
45 | | - * @return the result query |
46 | | - * @throws NullPointerException when there is null query |
| 77 | + * @param query the SQL-like query string |
| 78 | + * @param params a map of named parameters to bind in the query |
| 79 | + * @return a collection of matching entities |
| 80 | + * @throws NullPointerException if the query or params are null |
47 | 81 | */ |
48 | 82 | <T> Collection<T> sql(String query, Map<String, Object> params); |
49 | 83 |
|
50 | 84 | /** |
51 | | - * Executes hazelcast query |
| 85 | + * Executes a Hazelcast query using a {@link Predicate}. |
| 86 | + * <p> |
| 87 | + * The predicate-based approach is useful for filtering key-value pairs |
| 88 | + * based on specific criteria. |
| 89 | + * </p> |
52 | 90 | * |
53 | | - * @param predicate the hazelcast predicate |
54 | 91 | * @param <K> the key type |
55 | 92 | * @param <V> the value type |
56 | | - * @return the result query |
57 | | - * @throws NullPointerException when there is null predicate |
| 93 | + * @param predicate the Hazelcast predicate for filtering data |
| 94 | + * @return a collection of values that match the predicate |
| 95 | + * @throws NullPointerException if the predicate is null |
58 | 96 | */ |
59 | 97 | <K, V> Collection<V> sql(Predicate<K, V> predicate); |
60 | 98 |
|
|
0 commit comments