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