1
1
/*
2
- * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
2
+ * Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
26
26
* <p>Requests sorting on a given entity attribute.</p>
27
27
*
28
28
* <p>An instance of {@code Sort} specifies a sorting criterion based
29
- * on an entity field , with a sorting {@linkplain Direction direction}
29
+ * on an entity attribute , with a sorting {@linkplain Direction direction}
30
30
* and well-defined case sensitivity.</p>
31
31
*
32
32
* <p>A query method of a repository may have a parameter or parameters
83
83
* sort criteria.</p>
84
84
*
85
85
*
86
- * @param <T> entity class of the property upon which to sort.
87
- * @param property name of the property to order by.
88
- * @param isAscending whether ordering for this property is ascending (true) or descending (false).
86
+ * @param <T> entity class of the entity attribute upon which to sort.
87
+ * @param property name of the entity attribute to order by.
88
+ * @param isAscending whether ordering for this attribute is ascending (true) or descending (false).
89
89
* @param ignoreCase whether or not to request case insensitive ordering from a database with case sensitive collation.
90
90
*/
91
91
public record Sort <T >(String property , boolean isAscending , boolean ignoreCase ) {
92
92
93
93
/**
94
- * <p>Defines sort criteria for an entity property . For more descriptive code, use:</p>
94
+ * <p>Defines sort criteria for an entity attribute . For more descriptive code, use:</p>
95
95
* <ul>
96
- * <li>{@link #asc(String) Sort.asc(propertyName)} for ascending sort on a property.</li>
97
- * <li>{@link #ascIgnoreCase(String) Sort.ascIgnoreCase(propertyName)} for case insensitive ascending sort on a property.</li>
98
- * <li>{@link #desc(String) Sort.desc(propertyName)} for descending sort on a property.</li>
99
- * <li>{@link #descIgnoreCase(String) Sort.descIgnoreCase(propertyName)} for case insensitive descending sort on a property.</li>
96
+ * <li>{@link #asc(String) Sort.asc(attributeName)}
97
+ * for ascending sort on an entity attribute.</li>
98
+ * <li>{@link #ascIgnoreCase(String) Sort.ascIgnoreCase(attributeName)}
99
+ * for case insensitive ascending sort on an entity attribute.</li>
100
+ * <li>{@link #desc(String) Sort.desc(attributeName)}
101
+ * for descending sort on an entity attribute.</li>
102
+ * <li>{@link #descIgnoreCase(String) Sort.descIgnoreCase(attributeName)}
103
+ * for case insensitive descending sort on an entity attribute.</li>
100
104
* </ul>
101
105
*
102
- * @param property name of the property to order by.
103
- * @param isAscending whether ordering for this property is ascending (true) or descending (false).
106
+ * @param property name of the entity attribute to order by.
107
+ * @param isAscending whether ordering for this attribute is ascending (true) or descending (false).
104
108
* @param ignoreCase whether or not to request case insensitive ordering from a database with case sensitive collation.
105
109
*/
106
110
public Sort {
@@ -109,9 +113,9 @@ public record Sort<T>(String property, boolean isAscending, boolean ignoreCase)
109
113
110
114
// Override to provide method documentation:
111
115
/**
112
- * Name of the property to order by.
116
+ * Name of the entity attribute to order by.
113
117
*
114
- * @return The property name to order by; will never be {@code null}.
118
+ * @return The attribute name to order by; will never be {@code null}.
115
119
*/
116
120
public String property () {
117
121
return property ;
@@ -124,26 +128,28 @@ public String property() {
124
128
* A database with case insensitive collation performs case insensitive
125
129
* ordering regardless of the requested {@code ignoreCase} value.</p>
126
130
*
127
- * @return Returns whether or not to request case insensitive sorting for the property .
131
+ * @return Returns whether or not to request case insensitive sorting for the entity attribute .
128
132
*/
129
133
public boolean ignoreCase () {
130
134
return ignoreCase ;
131
135
}
132
136
133
137
// Override to provide method documentation:
134
138
/**
135
- * Indicates whether to sort the property in ascending order (true) or descending order (false).
139
+ * Indicates whether to sort the entity attribute in ascending order (true)
140
+ * or descending order (false).
136
141
*
137
- * @return Returns whether sorting for this property shall be ascending.
142
+ * @return Returns whether sorting for this attribute shall be ascending.
138
143
*/
139
144
public boolean isAscending () {
140
145
return isAscending ;
141
146
}
142
147
143
148
/**
144
- * Indicates whether to sort the property in descending order (true) or ascending order (false).
149
+ * Indicates whether to sort the entity attribute in descending order (true)
150
+ * or ascending order (false).
145
151
*
146
- * @return Returns whether sorting for this property shall be descending.
152
+ * @return Returns whether sorting for this attribute shall be descending.
147
153
*/
148
154
public boolean isDescending () {
149
155
return !isAscending ;
@@ -152,67 +158,67 @@ public boolean isDescending() {
152
158
/**
153
159
* Create a {@link Sort} instance
154
160
*
155
- * @param <T> entity class of the sortable property .
156
- * @param property the property name to order by
157
- * @param direction the direction in which to order.
161
+ * @param <T> entity class of the sortable entity attribute .
162
+ * @param attribute name of the entity attribute to order by
163
+ * @param direction the direction in which to order.
158
164
* @param ignoreCase whether to request a case insensitive ordering.
159
165
* @return a {@link Sort} instance. Never {@code null}.
160
166
* @throws NullPointerException when there is a null parameter
161
167
*/
162
- public static <T > Sort <T > of (String property , Direction direction , boolean ignoreCase ) {
168
+ public static <T > Sort <T > of (String attribute , Direction direction , boolean ignoreCase ) {
163
169
Objects .requireNonNull (direction , "direction is required" );
164
- return new Sort <>(property , Direction .ASC .equals (direction ), ignoreCase );
170
+ return new Sort <>(attribute , Direction .ASC .equals (direction ), ignoreCase );
165
171
}
166
172
167
173
/**
168
174
* Create a {@link Sort} instance with {@link Direction#ASC ascending direction}
169
175
* that does not request case insensitive ordering.
170
176
*
171
- * @param <T> entity class of the sortable property .
172
- * @param property the property name to order by
177
+ * @param <T> entity class of the sortable entity attribute .
178
+ * @param attribute name of the entity attribute to order by
173
179
* @return a {@link Sort} instance. Never {@code null}.
174
- * @throws NullPointerException when the property is null
180
+ * @throws NullPointerException when the attribute name is null
175
181
*/
176
- public static <T > Sort <T > asc (String property ) {
177
- return new Sort <>(property , true , false );
182
+ public static <T > Sort <T > asc (String attribute ) {
183
+ return new Sort <>(attribute , true , false );
178
184
}
179
185
180
186
/**
181
187
* Create a {@link Sort} instance with {@link Direction#ASC ascending direction}
182
188
* and case insensitive ordering.
183
189
*
184
- * @param <T> entity class of the sortable property .
185
- * @param property the property name to order by.
190
+ * @param <T> entity class of the sortable entity attribute .
191
+ * @param attribute name of the entity attribute to order by.
186
192
* @return a {@link Sort} instance. Never {@code null}.
187
- * @throws NullPointerException when the property is null.
193
+ * @throws NullPointerException when the attribute name is null.
188
194
*/
189
- public static <T > Sort <T > ascIgnoreCase (String property ) {
190
- return new Sort <>(property , true , true );
195
+ public static <T > Sort <T > ascIgnoreCase (String attribute ) {
196
+ return new Sort <>(attribute , true , true );
191
197
}
192
198
193
199
/**
194
200
* Create a {@link Sort} instance with {@link Direction#DESC descending direction}
195
201
* that does not request case insensitive ordering.
196
202
*
197
- * @param <T> entity class of the sortable property .
198
- * @param property the property name to order by
203
+ * @param <T> entity class of the sortable entity attribute .
204
+ * @param attribute name of the entity attribute to order by
199
205
* @return a {@link Sort} instance. Never {@code null}.
200
- * @throws NullPointerException when the property is null
206
+ * @throws NullPointerException when the attribute name is null
201
207
*/
202
- public static <T > Sort <T > desc (String property ) {
203
- return new Sort <>(property , false , false );
208
+ public static <T > Sort <T > desc (String attribute ) {
209
+ return new Sort <>(attribute , false , false );
204
210
}
205
211
206
212
/**
207
213
* Create a {@link Sort} instance with {@link Direction#DESC descending direction}
208
214
* and case insensitive ordering.
209
215
*
210
- * @param <T> entity class of the sortable property .
211
- * @param property the property name to order by.
216
+ * @param <T> entity class of the sortable entity attribute .
217
+ * @param attribute name of the entity attribute to order by.
212
218
* @return a {@link Sort} instance. Never {@code null}.
213
- * @throws NullPointerException when the property is null.
219
+ * @throws NullPointerException when the attribute name is null.
214
220
*/
215
- public static <T > Sort <T > descIgnoreCase (String property ) {
216
- return new Sort <>(property , false , true );
221
+ public static <T > Sort <T > descIgnoreCase (String attribute ) {
222
+ return new Sort <>(attribute , false , true );
217
223
}
218
224
}
0 commit comments