public PartitionChangeMove<Solution_> relocate( InnerScoreDirector<Solution_> destinationScoreDirector) { Map<GenuineVariableDescriptor<Solution_>, List<Pair<Object, Object>>> destinationChangeMap = new LinkedHashMap<>(changeMap.size()); for (Map.Entry<GenuineVariableDescriptor<Solution_>, List<Pair<Object, Object>>> entry : changeMap.entrySet()) { GenuineVariableDescriptor<Solution_> variableDescriptor = entry.getKey(); List<Pair<Object, Object>> originPairList = entry.getValue(); List<Pair<Object, Object>> destinationPairList = new ArrayList<>(originPairList.size()); for (Pair<Object, Object> pair : originPairList) { Object originEntity = pair.getKey(); Object destinationEntity = destinationScoreDirector.locateWorkingObject(originEntity); if (destinationEntity == null && originEntity != null) { throw new IllegalStateException( "The destinationEntity (" + destinationEntity + ") cannot be null if the originEntity (" + originEntity + ") is not null."); } Object originValue = pair.getValue(); Object destinationValue = destinationScoreDirector.locateWorkingObject(originValue); if (destinationValue == null && originValue != null) { throw new IllegalStateException( "The destinationValue (" + destinationValue + ") cannot be null if the originValue (" + originValue + ") is not null."); } destinationPairList.add(Pair.of(destinationEntity, destinationValue)); } destinationChangeMap.put(variableDescriptor, destinationPairList); } return new PartitionChangeMove<>(destinationChangeMap); }