@Test public void shouldNotMoveLowerThanUsedVariables_MoveToMiddle() { final FieldConstraint[] fieldConstraints = new FieldConstraint[3]; final SingleFieldConstraint top = new SingleFieldConstraint(); top.setFieldBinding("a"); fieldConstraints[0] = top; final SingleFieldConstraint middle = new SingleFieldConstraint(); middle.setConstraintValueType(BaseSingleFieldConstraint.TYPE_VARIABLE); middle.setValue("a"); fieldConstraints[1] = middle; final SingleFieldConstraint bottom = new SingleFieldConstraint(); bottom.setConstraintValueType(BaseSingleFieldConstraint.TYPE_VARIABLE); bottom.setValue("b"); fieldConstraints[2] = bottom; FieldConstraintArrayUtil.moveDown(0, fieldConstraints); FieldConstraintArrayUtil.moveDown(1, fieldConstraints); assertEquals(top, fieldConstraints[0]); assertEquals(bottom, fieldConstraints[1]); assertEquals(middle, fieldConstraints[2]); }
public static void moveDown(int index, FieldConstraint[] fieldConstraints) { if (index < (fieldConstraints.length - 1)) { final FieldConstraint first = fieldConstraints[index]; final FieldConstraint second = fieldConstraints[index + 1]; if (blockSwap(first, second)) { return; } fieldConstraints[index] = second; fieldConstraints[index + 1] = first; } }
FieldConstraintArrayUtil { public static void moveDown(int index, FieldConstraint[] fieldConstraints) { if (index < (fieldConstraints.length - 1)) { final FieldConstraint first = fieldConstraints[index]; final FieldConstraint second = fieldConstraints[index + 1]; if (blockSwap(first, second)) { return; } fieldConstraints[index] = second; fieldConstraints[index + 1] = first; } } }
FieldConstraintArrayUtil { public static void moveDown(int index, FieldConstraint[] fieldConstraints) { if (index < (fieldConstraints.length - 1)) { final FieldConstraint first = fieldConstraints[index]; final FieldConstraint second = fieldConstraints[index + 1]; if (blockSwap(first, second)) { return; } fieldConstraints[index] = second; fieldConstraints[index + 1] = first; } } private  FieldConstraintArrayUtil(); }
FieldConstraintArrayUtil { public static void moveDown(int index, FieldConstraint[] fieldConstraints) { if (index < (fieldConstraints.length - 1)) { final FieldConstraint first = fieldConstraints[index]; final FieldConstraint second = fieldConstraints[index + 1]; if (blockSwap(first, second)) { return; } fieldConstraints[index] = second; fieldConstraints[index + 1] = first; } } private  FieldConstraintArrayUtil(); static void moveDown(int index, FieldConstraint[] fieldConstraints); static void moveUp(int index, FieldConstraint[] fieldConstraints); }
FieldConstraintArrayUtil { public static void moveDown(int index, FieldConstraint[] fieldConstraints) { if (index < (fieldConstraints.length - 1)) { final FieldConstraint first = fieldConstraints[index]; final FieldConstraint second = fieldConstraints[index + 1]; if (blockSwap(first, second)) { return; } fieldConstraints[index] = second; fieldConstraints[index + 1] = first; } } private  FieldConstraintArrayUtil(); static void moveDown(int index, FieldConstraint[] fieldConstraints); static void moveUp(int index, FieldConstraint[] fieldConstraints);  }