Skip to content

Commit 3bab504

Browse files
committed
docs: enhance documentation to HazelcastTemplate
Signed-off-by: Otavio Santana <[email protected]>
1 parent 31cbfe4 commit 3bab504

File tree

1 file changed

+53
-15
lines changed

1 file changed

+53
-15
lines changed

jnosql-hazelcast/src/main/java/org/eclipse/jnosql/databases/hazelcast/mapping/HazelcastTemplate.java

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,78 @@
2121
import java.util.Map;
2222

2323
/**
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
2549
*/
2650
public interface HazelcastTemplate extends KeyValueTemplate {
2751

2852
/**
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>
3057
*
3158
* @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
3562
*/
3663
<T> Collection<T> sql(String query);
3764

3865
/**
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>
4175
*
42-
* @param query the query
4376
* @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
4781
*/
4882
<T> Collection<T> sql(String query, Map<String, Object> params);
4983

5084
/**
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>
5290
*
53-
* @param predicate the hazelcast predicate
5491
* @param <K> the key type
5592
* @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
5896
*/
5997
<K, V> Collection<V> sql(Predicate<K, V> predicate);
6098

0 commit comments

Comments
 (0)