Skip to content

Commit

Permalink
Refactor DumperConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 2, 2023
1 parent 8c8a552 commit b5fecd5
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class DumperConfiguration {

// LinkedHashSet is required
@Getter(AccessLevel.PROTECTED)
private Map<LogicTableName, Set<ColumnName>> targetTableColumnsMap;
private Map<LogicTableName, Set<ColumnName>> targetTableColumnsMap = new HashMap<>();

private boolean decodeWithTX;

Expand Down Expand Up @@ -113,8 +114,9 @@ public String getSchemaName(final ActualTableName actualTableName) {
* @return column names
*/
public Collection<String> getColumnNames(final LogicTableName logicTableName) {
Collection<ColumnName> columnNames = null == targetTableColumnsMap ? null : targetTableColumnsMap.get(logicTableName);
return null == columnNames ? Collections.singleton("*") : columnNames.stream().map(ColumnName::getOriginal).collect(Collectors.toList());
return targetTableColumnsMap.containsKey(logicTableName)
? targetTableColumnsMap.get(logicTableName).stream().map(ColumnName::getOriginal).collect(Collectors.toList())
: Collections.singleton("*");
}

/**
Expand All @@ -124,7 +126,6 @@ public Collection<String> getColumnNames(final LogicTableName logicTableName) {
* @return column names
*/
public Collection<ColumnName> getColumnNames(final String actualTableName) {
Set<ColumnName> result = null == targetTableColumnsMap ? null : targetTableColumnsMap.get(getLogicTableName(actualTableName));
return null == result ? Collections.emptySet() : result;
return targetTableColumnsMap.getOrDefault(getLogicTableName(actualTableName), Collections.emptySet());
}
}

0 comments on commit b5fecd5

Please sign in to comment.