|
6 | 6 | import java.lang.annotation.RetentionPolicy; |
7 | 7 | import java.lang.annotation.Target; |
8 | 8 |
|
| 9 | +/** |
| 10 | + * Annotation used to describe whether a JPA bean property can be searched, filtered, sorted or |
| 11 | + * dynamically resolved by the query engine. |
| 12 | + * |
| 13 | + * <p>This annotation provides metadata to drive the construction of dynamic Spring Specifications |
| 14 | + * and to expose query capabilities to higher-level components (API, UI, query builders, etc.). |
| 15 | + * |
| 16 | + * <p>It can be applied to fields or getter methods. |
| 17 | + */ |
9 | 18 | @Retention(RetentionPolicy.RUNTIME) |
10 | 19 | @Target({ElementType.FIELD, ElementType.METHOD}) |
11 | 20 | public @interface Queryable { |
| 21 | + |
| 22 | + /** |
| 23 | + * Enables free-text search on this property (e.g. using LIKE/ILIKE operators depending on the |
| 24 | + * backend). |
| 25 | + */ |
12 | 26 | boolean searchable() default false; |
13 | 27 |
|
| 28 | + /** Allows filtering this property using supported filter operators. */ |
14 | 29 | boolean filterable() default false; |
15 | 30 |
|
| 31 | + /** |
| 32 | + * Indicates that the property refers to another entity stored in the database, meaning its |
| 33 | + * possible filter values must be retrieved dynamically. Typically used for relations (ManyToOne, |
| 34 | + * OneToMany, etc.). |
| 35 | + */ |
16 | 36 | boolean dynamicValues() default false; |
17 | 37 |
|
| 38 | + /** Allows sorting results based on this property. */ |
18 | 39 | boolean sortable() default false; |
19 | 40 |
|
| 41 | + /** Human-readable label used for documentation or UI generation. */ |
20 | 42 | String label() default ""; |
21 | 43 |
|
| 44 | + /** |
| 45 | + * Defines the JPA path used to query this property. Follows Spring Data Specification conventions |
| 46 | + * (e.g. {@code "organization.id"}). |
| 47 | + */ |
22 | 48 | String path() default ""; |
23 | 49 |
|
| 50 | + /** |
| 51 | + * Defines multiple possible JPA paths, when the property can be resolved through different |
| 52 | + * relationships or aliases. |
| 53 | + */ |
24 | 54 | String[] paths() default {}; |
25 | 55 |
|
26 | 56 | Filters.FilterOperator[] overrideOperators() default {}; |
|
29 | 59 |
|
30 | 60 | Class refEnumClazz() default Unassigned.class; |
31 | 61 |
|
32 | | - // use this absolutely specific class as a "null" value for class, refEnumClazz |
33 | | - // don't use Void here because that is a legitimate return type |
34 | | - // although there is little to justify having a queryable void method |
| 62 | + /** |
| 63 | + * Special sentinel class used to represent an "unassigned" state for {@link #clazz()} and {@link |
| 64 | + * #refEnumClazz()}. |
| 65 | + * |
| 66 | + * <p>We cannot use {@code Void.class} here since {@code void} is a valid type and could lead to |
| 67 | + * ambiguity. |
| 68 | + */ |
35 | 69 | class Unassigned {} |
36 | 70 | } |
0 commit comments