Skip to content

Commit

Permalink
Merge pull request #6 from SAP/develop
Browse files Browse the repository at this point in the history
Remove JDK17 specific syntax
  • Loading branch information
lnowakowski authored Aug 21, 2023
2 parents 0452c4e + aae2a4a commit d54a441
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javax.annotation.concurrent.Immutable;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import static java.sql.Types.CHAR;
import static java.sql.Types.SMALLINT;
Expand All @@ -32,7 +33,7 @@ public DefaultDataSet(int batchId, int columnCount, List<DataColumn> columnOrder
this.batchId = batchId;
this.columnCount = columnCount;
this.columnOrder = Collections.unmodifiableList(columnOrder);
this.result = result.stream().map(Collections::unmodifiableList).toList();
this.result = result.stream().map(Collections::unmodifiableList).collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public Object execute() throws Exception {
});
} catch (final Exception e) {
LOG.error("Error during PostProcessor execution", e);
if (e instanceof RuntimeException re) {
throw re;
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ protected String getBulkUpdateStatementParamList(List<String> columnsToCopy, Lis
List<String> upsertIDs) {
final String upsertID = upsertIDs.get(0); // TODO handle multiple upsert IDs if needed
final List<String> columnsToCopyMinusPK = columnsToCopy.stream().filter(s -> !s.equalsIgnoreCase(upsertID))
.toList();
.collect(Collectors.toList());
final List<String> columnsToCopyValuesMinusPK = columnsToCopyValues.stream()
.filter(s -> !s.equalsIgnoreCase("s." + upsertID)).toList();
.filter(s -> !s.equalsIgnoreCase("s." + upsertID)).collect(Collectors.toList());
LOG.debug("getBulkUpdateStatementParamList - columnsToCopyMinusPK =" + columnsToCopyMinusPK);
return "SET " + IntStream.range(0, columnsToCopyMinusPK.size()).mapToObj(
idx -> String.format("%s = %s", columnsToCopyMinusPK.get(idx), columnsToCopyValuesMinusPK.get(idx)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ protected String getBulkUpdateStatementParamList(List<String> columnsToCopy, Lis
List<String> upsertIDs) {
final String upsertID = upsertIDs.get(0);
final List<String> columnsToCopyMinusPK = columnsToCopy.stream().filter(s -> !s.equalsIgnoreCase(upsertID))
.toList();
.collect(Collectors.toList());
final List<String> columnsToCopyValuesMinusPK = columnsToCopyValues.stream()
.filter(s -> !s.equalsIgnoreCase("s." + upsertID)).toList();
.filter(s -> !s.equalsIgnoreCase("s." + upsertID)).collect(Collectors.toList());
LOG.debug("getBulkUpdateStatementParamList - columnsToCopyMinusPK =" + columnsToCopyMinusPK);
return "SET " + IntStream.range(0, columnsToCopyMinusPK.size()).mapToObj(
idx -> String.format("%s = %s", columnsToCopyMinusPK.get(idx), columnsToCopyValuesMinusPK.get(idx)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ private String detectSize(Column column) {
public void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable,
Table targetTable, Map parameters, List changes) throws IOException {
Iterator changeIt = changes.iterator();
Object change;

while (changeIt.hasNext()) {
if (changeIt.next()instanceof RemoveColumnChange removeColumnChange) {
processChange(currentModel, desiredModel, removeColumnChange);
change = changeIt.next();
if (change instanceof RemoveColumnChange) {
processChange(currentModel, desiredModel, (RemoveColumnChange) change);
changeIt.remove();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ private void process() throws Exception {
+ sourceColumnValue.getClass().getTypeName());
printedClobLog = true;
}
if (sourceColumnValue instanceof String clobString) {
if (sourceColumnValue instanceof String) {
String clobString = (String) sourceColumnValue;
if (!clobString.isEmpty()) {
LOG.debug(" reading CLOB");
bulkWriterStatement.setClob(paramIdx,
Expand All @@ -224,11 +225,12 @@ private void process() throws Exception {
+ ", targetColumnType =" + targetColumnType + ", source type = "
+ sourceColumnValue.getClass().getTypeName());
if (dbProvider.isOracleUsed()) {
if (targetColumnType == NUMERIC
&& sourceColumnValue instanceof String stringValue
&& !stringValue.isEmpty()) {
final int character = Character.codePointAt(stringValue, 0);
bulkWriterStatement.setInt(paramIdx, character);
if (targetColumnType == NUMERIC && sourceColumnValue instanceof String) {
final String stringValue = (String) sourceColumnValue;
if (!stringValue.isEmpty()) {
final int character = Character.codePointAt(stringValue, 0);
bulkWriterStatement.setInt(paramIdx, character);
}
}
}
} catch (final Exception e) {
Expand Down

0 comments on commit d54a441

Please sign in to comment.