|
36 | 36 | *
|
37 | 37 | * // Find all Product entities where the price field is less than a maximum value.
|
38 | 38 | * @Find
|
39 |
| - * List<Product> pricedBelow(@By(_Product.PRICE) @Is(LessThan) float max); |
| 39 | + * List<Product> pricedBelow(@By(_Product.PRICE) @Is(LESS_THAN) float max); |
40 | 40 | *
|
41 | 41 | * // Find a page of Product entities where the name field matches a pattern, ignoring case.
|
42 | 42 | * @Find
|
43 |
| - * Page<Product> search(@By(_Product.NAME) @Is(LikeIgnoreCase) String pattern, |
| 43 | + * Page<Product> search(@By(_Product.NAME) @Is(LIKE_IGNORE_CASE) String pattern, |
44 | 44 | * PageRequest pagination,
|
45 | 45 | * Order<Product> order);
|
46 | 46 | *
|
47 | 47 | * // Remove Product entities with any of the unique identifiers listed.
|
48 | 48 | * @Delete
|
49 |
| - * void remove(@By(ID) @Is(In) List<Long> productIds); |
| 49 | + * void remove(@By(ID) @Is(IN) List<Long> productIds); |
50 | 50 | * }
|
51 | 51 | * </pre>
|
52 | 52 | */
|
53 | 53 | @Retention(RetentionPolicy.RUNTIME)
|
54 | 54 | @Target(ElementType.PARAMETER)
|
55 | 55 | public @interface Is {
|
| 56 | + // TODO add JavaDoc with examples to these |
| 57 | + String EQUAL = "EQUAL"; |
| 58 | + String GREATER_THAN = "GREATER_THAN"; |
| 59 | + String GREATER_THAN_EQ = "GREATER_THAN_EQ"; |
| 60 | + String IGNORE_CASE = "IGNORE_CASE"; |
| 61 | + String IN = "IN"; |
| 62 | + String LESS_THAN = "LESS_THAN"; |
| 63 | + String LESS_THAN_EQ = "LESS_THAN_EQ"; |
| 64 | + String LIKE = "LIKE"; |
| 65 | + String LIKE_IGNORE_CASE = "LIKE_IGNORE_CASE"; |
| 66 | + String NOT = "NOT"; |
| 67 | + String NOT_IGNORE_CASE = "NOT_IGNORE_CASE"; |
| 68 | + String NOT_IN = "NOT_IN"; |
| 69 | + String NOT_LIKE = "NOT_LIKE"; |
| 70 | + String NOT_LIKE_IGNORE_CASE = "NOT_LIKE_IGNORE_CASE"; |
| 71 | + |
56 | 72 | /**
|
57 | 73 | * <p>The type of comparison operation to use when comparing a persistent
|
58 |
| - * field against a value that is supplied to a repository method.</p> |
| 74 | + * field against a value that is supplied to a repository method. |
| 75 | + * For portable applications, the comparison operation must be one of the |
| 76 | + * constants defined within this class. Jakarta Data providers might choose |
| 77 | + * to provide their own constants as non-portable extensions.</p> |
59 | 78 | *
|
60 | 79 | * <p>The following example compares the year a person was born against
|
61 | 80 | * a minimum and maximum year that are supplied as parameters to a repository
|
|
64 | 83 | * <pre>
|
65 | 84 | * @Find
|
66 | 85 | * @OrderBy(_Person.YEAR_BORN)
|
67 |
| - * List<Person> bornWithin(@By(_Person.YEAR_BORN) @Is(GreaterThanEqual) float minYear, |
68 |
| - * @By(_Person.YEAR_BORN) @Is(LessThanEqual) float maxYear); |
| 86 | + * List<Person> bornWithin(@By(_Person.YEAR_BORN) @Is(TREATER_THAN_EQ) float minYear, |
| 87 | + * @By(_Person.YEAR_BORN) @Is(LESS_THAN_EQ) float maxYear); |
69 | 88 | * </pre>
|
70 | 89 | *
|
71 |
| - * <p>The default comparison operation is the {@linkplain Op#Equal equality} |
72 |
| - * comparison.</p> |
73 |
| - * |
74 |
| - * @return the type of comparison operation. |
75 |
| - */ |
76 |
| - Op value() default Op.Equal; |
77 |
| - |
78 |
| - /** |
79 |
| - * <p>Comparison operations for the {@link Is} annotation.</p> |
| 90 | + * <p>The default comparison operation is the {@linkplain #EQUAL equality} |
| 91 | + * comparison.</p> |
80 | 92 | *
|
81 |
| - * <p>For more concise code, it can be convenient to statically import one |
82 |
| - * or more comparison operations. For example:</p> |
| 93 | + * <p>For concise code, it can be convenient for a repository interface to |
| 94 | + * statically import one or more constants from this class. For example:</p> |
83 | 95 | *
|
84 | 96 | * <pre>
|
85 |
| - * import static jakarta.data.repository.Is.Op.*; |
| 97 | + * import static jakarta.data.repository.Is.*; |
86 | 98 | * </pre>
|
| 99 | + * |
| 100 | + * @return the type of comparison operation. |
87 | 101 | */
|
88 |
| - public static enum Op { |
89 |
| - // TODO add JavaDoc with examples to these |
90 |
| - Equal, |
91 |
| - GreaterThan, |
92 |
| - GreaterThanEqual, |
93 |
| - IgnoreCase, |
94 |
| - In, |
95 |
| - LessThan, |
96 |
| - LessThanEqual, |
97 |
| - Like, |
98 |
| - LikeIgnoreCase, |
99 |
| - // TODO might want to give more thought to the exact names, |
100 |
| - Prefixed, |
101 |
| - PrefixedIgnoreCase, |
102 |
| - Substringed, |
103 |
| - SubstringedIgnoreCase, |
104 |
| - Suffixed, |
105 |
| - SuffixedIgnoreCase, |
106 |
| - Not, |
107 |
| - NotIgnoreCase, |
108 |
| - NotIn, |
109 |
| - NotLike, |
110 |
| - NotLikeIgnoreCase, |
111 |
| - NotPrefixed, |
112 |
| - NotPrefixedIgnoreCase, |
113 |
| - NotSubstringed, |
114 |
| - NotSubstringedIgnoreCase, |
115 |
| - NotSuffixed, |
116 |
| - NotSuffixedIgnoreCase; |
117 |
| - } |
| 102 | + String value() default EQUAL; |
118 | 103 | }
|
0 commit comments