Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
sualeh committed Apr 21, 2023
1 parent ed00711 commit e9cbfac
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public SchemaRetrievalOptionsBuilder with(

if (metadataRetrievalStrategy == null) {
// Reset to default
metadataRetrievalStrategyMap.put(
schemaInfoMetadataRetrievalStrategy, MetadataRetrievalStrategy.metadata);
metadataRetrievalStrategyMap.put(schemaInfoMetadataRetrievalStrategy, metadata);
} else {
metadataRetrievalStrategyMap.put(
schemaInfoMetadataRetrievalStrategy, metadataRetrievalStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static Map<SQLType, Class<?>> createDefaultTypeMap() {
defaultTypeMap.put(JDBCType.OTHER, Object.class);
defaultTypeMap.put(JDBCType.REAL, Float.class);
defaultTypeMap.put(JDBCType.REF, java.sql.Ref.class);
defaultTypeMap.put(JDBCType.REF_CURSOR, java.lang.Object.class);
defaultTypeMap.put(JDBCType.REF_CURSOR, Object.class);
defaultTypeMap.put(JDBCType.ROWID, java.sql.RowId.class);
defaultTypeMap.put(JDBCType.SMALLINT, Integer.class);
defaultTypeMap.put(JDBCType.SQLXML, java.sql.SQLXML.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import picocli.CommandLine;
import picocli.CommandLine.PicocliException;
import schemacrawler.tools.commandline.state.ShellState;
import schemacrawler.tools.commandline.state.StateFactory;
import schemacrawler.tools.commandline.utility.CommandLineLogger;
Expand Down Expand Up @@ -103,7 +104,7 @@ private static void executeCommandLine(final CommandLine commandLine) {

private static String extractErrorMessage(final Throwable throwable) {
final String errorMessage;
if (throwable instanceof picocli.CommandLine.PicocliException) {
if (throwable instanceof PicocliException) {
final Throwable cause = throwable.getCause();
if (cause != null && !isBlank(cause.getMessage())) {
errorMessage = cause.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import picocli.CommandLine;
import picocli.CommandLine.PicocliException;
import picocli.shell.jline3.PicocliCommands;
import picocli.shell.jline3.PicocliCommands.PicocliCommandsFactory;
import schemacrawler.tools.commandline.state.ShellState;
Expand Down Expand Up @@ -159,7 +160,7 @@ private static void handleFatalError(
commandLineLogger.logState(state);

final String errorMessage;
if (throwable instanceof picocli.CommandLine.PicocliException) {
if (throwable instanceof PicocliException) {
final Throwable cause = throwable.getCause();
if (cause != null && !isBlank(cause.getMessage())) {
errorMessage = cause.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
package schemacrawler.tools.lint;

import static java.util.Objects.requireNonNull;

import java.io.Serializable;
import java.sql.Connection;
import java.util.ArrayList;
Expand All @@ -38,7 +37,6 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import schemacrawler.filter.TableTypesFilter;
import schemacrawler.inclusionrule.IncludeAll;
import schemacrawler.inclusionrule.InclusionRule;
Expand Down Expand Up @@ -87,7 +85,9 @@ protected final <V extends Serializable> void addTableLint(
addLint(LintObjectType.table, table, message, value);
}

protected void end(final Connection connection) {}
protected void end(final Connection connection) {
// Default implementation - NO-OP
}

protected final List<Column> getColumns(final Table table) {
if (table == null) {
Expand Down Expand Up @@ -130,7 +130,9 @@ protected final void setTableTypesFilter(final TableTypesFilter tableTypesFilter
}
}

protected void start(final Connection connection) {}
protected void start(final Connection connection) {
// Default implementation - NO-OP
}

@Override
final void configure(final LinterConfig linterConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static java.util.Comparator.naturalOrder;
import static java.util.Objects.requireNonNull;
import static us.fatehi.utility.Utility.convertForComparison;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -41,17 +40,15 @@
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import schemacrawler.schema.Column;
import schemacrawler.schema.ColumnDataType;
import schemacrawler.schema.Table;
import schemacrawler.tools.lint.BaseLinter;
import us.fatehi.utility.Multimap;
import us.fatehi.utility.Utility;

public class LinterTableWithIncrementingColumns extends BaseLinter {

private class IncrementingColumn {
private static class IncrementingColumn {
private final int columnIncrement;
private final Column column;

Expand Down Expand Up @@ -162,7 +159,7 @@ private Multimap<String, IncrementingColumn> findIncrementingColumns(final List<
final Multimap<String, IncrementingColumn> incrementingColumns = new Multimap<>();

for (final Column column : columns) {
final String columnName = Utility.convertForComparison(column.getName());
final String columnName = convertForComparison(column.getName());
if (incrementingColumnsMap.containsKey(columnName)) {
incrementingColumns.add(columnName, new IncrementingColumn("0", column));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@

import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;

import java.beans.ConstructorProperties;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -61,7 +59,7 @@ public CatalogAttributes(
final List<AlternateKeyAttributes> alternateKeys) {
super(name, remarks, attributes);
if (tables == null) {
this.tables = Collections.emptyList();
this.tables = emptyList();
} else {
this.tables = unmodifiableList(tables);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,19 @@ public void handle(final JdbcDriverInfo driverInfo) {
}

@Override
public final void handleHeaderEnd() {}
public final void handleHeaderEnd() {
// Default implementation - NO-OP
}

@Override
public final void handleHeaderStart() {}
public final void handleHeaderStart() {
// Default implementation - NO-OP
}

@Override
public final void handleInfoEnd() {}
public final void handleInfoEnd() {
// Default implementation - NO-OP
}

@Override
public final void handleInfoStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static schemacrawler.tools.executable.commandline.PluginCommandType.server;
import static schemacrawler.tools.executable.commandline.PluginCommandType.unknown;
import static us.fatehi.utility.Utility.isBlank;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -154,7 +153,7 @@ public boolean hasHelpDescription() {
}

public boolean hasHelpFooter() {
return helpFooter != null || type != PluginCommandType.unknown;
return helpFooter != null || type != unknown;
}

public boolean isEmpty() {
Expand Down

0 comments on commit e9cbfac

Please sign in to comment.