@@ -235,21 +235,19 @@ public final <Entity_, Value_> Value_ moveValueInList(
235235 "When moving values in the same list, sourceIndex (%d) and destinationIndex (%d) must be different."
236236 .formatted (sourceIndex , destinationIndex ));
237237 } else if (sourceIndex < 0 || destinationIndex < 0 ) {
238- throw new IllegalArgumentException (
239- "The sourceIndex (%d) and destinationIndex (%d) must both be >= 0."
240- .formatted (sourceIndex , destinationIndex ));
238+ throw new IndexOutOfBoundsException ("The sourceIndex (%d) and destinationIndex (%d) must both be >= 0."
239+ .formatted (sourceIndex , destinationIndex ));
241240 }
242241
243242 var variableDescriptor = extractVariableDescriptor (variableMetaModel );
244243 var list = variableDescriptor .getValue (sourceEntity );
245244 var listSize = list .size ();
246245 if (sourceIndex >= listSize ) {
247- throw new IllegalArgumentException (
248- "The sourceIndex (%d) must be less than the list size (%d)." .formatted (sourceIndex , listSize ));
246+ throw new IndexOutOfBoundsException ( "The sourceIndex (%d) must be less than the list size (%d)."
247+ .formatted (sourceIndex , listSize ));
249248 } else if (destinationIndex >= listSize ) {
250- throw new IllegalArgumentException (
251- "The destinationIndex (%d) must be less than the list size (%d)."
252- .formatted (destinationIndex , listSize ));
249+ throw new IndexOutOfBoundsException ("The destinationIndex (%d) must be less than the list size (%d)."
250+ .formatted (destinationIndex , listSize ));
253251 }
254252
255253 var fromIndex = Math .min (sourceIndex , destinationIndex );
@@ -270,9 +268,8 @@ public <Entity_, Value_> Value_ replaceValueInList(
270268 "When replacing values in the same list, sourceIndex (%d) and replacementIndex (%d) must be different."
271269 .formatted (sourceIndex , replacementIndex ));
272270 } else if (sourceIndex < 0 || replacementIndex < 0 ) {
273- throw new IllegalArgumentException (
274- "The sourceIndex (%d) and replacementIndex (%d) must both be >= 0."
275- .formatted (sourceIndex , replacementIndex ));
271+ throw new IndexOutOfBoundsException ("The sourceIndex (%d) and replacementIndex (%d) must both be >= 0."
272+ .formatted (sourceIndex , replacementIndex ));
276273 }
277274
278275 var variableDescriptor = extractVariableDescriptor (variableMetaModel );
@@ -327,7 +324,7 @@ private static <T> void moveInList(List<T> list, int from, int to) {
327324 }
328325 var lowerIndex = Math .min (from , to );
329326 var distanceTimesEight = (long ) distance * 8L ; // Prevents unlikely yet possible overflow.
330- var tailLength = ( long ) list .size () - lowerIndex ;
327+ var tailLength = list .size () - lowerIndex ;
331328 if (distanceTimesEight < tailLength ) {
332329 Collections .rotate (list .subList (lowerIndex , lowerIndex + distance + 1 ), from < to ? -1 : 1 );
333330 } else {
0 commit comments