Skip to content

Commit b5a034d

Browse files
committed
Better name
1 parent f9ace2d commit b5a034d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

core/src/main/java/ai/timefold/solver/core/impl/move/director/MoveDirector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public final <Entity_, Value_> void changeVariable(PlanningVariableMetaModel<Sol
8989
PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex,
9090
Entity_ destinationEntity, int destinationIndex) {
9191
if (sourceEntity == destinationEntity) {
92-
return swapValues(variableMetaModel, sourceEntity, sourceIndex, destinationIndex);
92+
return moveValueInList(variableMetaModel, sourceEntity, sourceIndex, destinationIndex);
9393
}
9494
var variableDescriptor = extractVariableDescriptor(variableMetaModel);
9595
externalScoreDirector.beforeListVariableChanged(variableDescriptor, sourceEntity, sourceIndex, sourceIndex + 1);
@@ -107,13 +107,13 @@ public final <Entity_, Value_> void changeVariable(PlanningVariableMetaModel<Sol
107107

108108
@SuppressWarnings("unchecked")
109109
@Override
110-
public final <Entity_, Value_> @Nullable Value_ swapValues(
110+
public final <Entity_, Value_> @Nullable Value_ moveValueInList(
111111
PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int sourceIndex,
112112
int destinationIndex) {
113113
if (sourceIndex == destinationIndex) {
114114
return null;
115115
} else if (sourceIndex > destinationIndex) { // Always start from the lower index.
116-
return swapValues(variableMetaModel, entity, destinationIndex, sourceIndex);
116+
return moveValueInList(variableMetaModel, entity, destinationIndex, sourceIndex);
117117
}
118118
var variableDescriptor = extractVariableDescriptor(variableMetaModel);
119119
var toIndex = destinationIndex + 1;

core/src/main/java/ai/timefold/solver/core/impl/move/streams/maybeapi/generic/move/ListChangeMove.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private Value_ getMovedValue() {
123123
@Override
124124
public void execute(MutableSolutionView<Solution_> solutionView) {
125125
if (sourceEntity == destinationEntity) {
126-
planningValue = solutionView.swapValues(variableMetaModel, sourceEntity, sourceIndex, destinationIndex);
126+
planningValue = solutionView.moveValueInList(variableMetaModel, sourceEntity, sourceIndex, destinationIndex);
127127
} else {
128128
planningValue = solutionView.moveValueBetweenLists(variableMetaModel, sourceEntity, sourceIndex, destinationEntity,
129129
destinationIndex);

core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ <Entity_, Value_> void changeVariable(PlanningVariableMetaModel<Solution_, Entit
125125
* @return the value that was moved; null if nothing was moved
126126
* @throws IndexOutOfBoundsException if the index is out of bounds
127127
*/
128-
<Entity_, Value_> @Nullable Value_ swapValues(
128+
<Entity_, Value_> @Nullable Value_ moveValueInList(
129129
PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int sourceIndex,
130130
int destinationIndex);
131131

core/src/test/java/ai/timefold/solver/core/impl/move/director/MoveDirectorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void readListVariable() {
120120
}
121121

122122
@Test
123-
void swapValues() {
123+
void moveValueInList() {
124124
var solutionMetaModel = TestdataListSolution.buildSolutionDescriptor()
125125
.getMetaModel();
126126
var variableMetaModel = solutionMetaModel.entity(TestdataListEntity.class)
@@ -137,7 +137,7 @@ void swapValues() {
137137
// Swap between second and last position.
138138
var mockScoreDirector = (InnerScoreDirector<TestdataListSolution, ?>) mock(InnerScoreDirector.class);
139139
var moveDirector = new MoveDirector<>(mockScoreDirector).ephemeral();
140-
moveDirector.swapValues(variableMetaModel, entity, 1, 2);
140+
moveDirector.moveValueInList(variableMetaModel, entity, 1, 2);
141141
assertThat(entity.getValueList()).containsExactly(expectedValue1, expectedValue3, expectedValue2);
142142
verify(mockScoreDirector).beforeListVariableChanged(variableDescriptor, entity, 1, 3);
143143
verify(mockScoreDirector).afterListVariableChanged(variableDescriptor, entity, 1, 3);
@@ -151,7 +151,7 @@ void swapValues() {
151151

152152
// Do the same in reverse.
153153
moveDirector = new MoveDirector<>(mockScoreDirector).ephemeral();
154-
moveDirector.swapValues(variableMetaModel, entity, 2, 1);
154+
moveDirector.moveValueInList(variableMetaModel, entity, 2, 1);
155155
assertThat(entity.getValueList()).containsExactly(expectedValue1, expectedValue3, expectedValue2);
156156
verify(mockScoreDirector).beforeListVariableChanged(variableDescriptor, entity, 1, 3);
157157
verify(mockScoreDirector).afterListVariableChanged(variableDescriptor, entity, 1, 3);

0 commit comments

Comments
 (0)