private void mergeRequiredRowWithUniqueKey(Table destinationTable, Row requiredRow) { List<Row> updatables = new ArrayList<Row>(); List<Row> incompatiblesRows = new ArrayList<Row>(); for (Row existingRow : destinationTable.getRows()) { if (checker.matchUniqueKey(requiredRow.getUniqueKey(), existingRow)) { if (checker.checkIncompatibilityIgnoringUniqueKey(requiredRow, existingRow)) { incompatiblesRows.add(existingRow); } else { updatables.add(existingRow); } } } if (!incompatiblesRows.isEmpty()) { throw new TokioLoaderException( computeErrorMessage(requiredRow, incompatiblesRows, CONFLICT_ERROR_MESSAGE)); } else if (updatables.size() > 1) { throw new TokioLoaderException( computeErrorMessage(requiredRow, updatables, TOO_MANY_ROWS_ERROR_MESSAGE)); } else if (updatables.size() == 1) { mergeFields(updatables.get(0), requiredRow); } else { destinationTable.addRow(requiredRow); } }