Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zhicwu committed Jan 15, 2021
1 parent e73159c commit cc8a4c0
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public abstract class BaseRepository<T extends ManagedEntity> implements Reposit
private final Class<T> clazz;
private final String name;
private final DnsResolver resolver;
private final List<UsageStats> stats;

private String defaultType = null;

Expand Down Expand Up @@ -229,7 +228,6 @@ public BaseRepository(Class<T> clazz) {
this.clazz = Objects.requireNonNull(clazz);
this.name = clazz.getSimpleName();
this.resolver = new DnsResolver();
this.stats = new ArrayList<>();

this.defaultExtension = new Extension<>(clazz);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public interface DataTypeConverter {
static final String M_FACET_SINGLE = "Single.Type";
static final String M_FACET_DOUBLE = "Double.Type";

@SuppressWarnings("unchecked")
default <T> T as(Class<T> type, Object value) {
final Object result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void initialize(ExtensionManager manager) {
* @throws IllegalArgumentException if failed to create new instance using
* given arguments
*/
@SuppressWarnings("unchecked")
public T newInstance(Object... args) {
final Thread current = Thread.currentThread();
final ClassLoader currentLoader = current.getContextClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class NamedDataSource extends ManagedEntity implements Closeable {

protected final DataTypeConverter converter;

@SuppressWarnings("unchecked")
public static NamedDataSource newInstance(Object... args) {
if (Objects.requireNonNull(args).length < 2) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class NamedQuery extends NamedSchema {

private final QueryParameters parameters;

@SuppressWarnings("unchecked")
public static NamedQuery newInstance(Object... args) {
if (Objects.requireNonNull(args).length < 2) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class NamedSchema extends ManagedEntity {

private final TableDefinition columns;

@SuppressWarnings("unchecked")
public static NamedSchema newInstance(Object... args) {
if (Objects.requireNonNull(args).length < 2) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public QueryParameters(JsonObject... params) {
public QueryParameters merge(QueryParameters p) {
if (p != null) {
for (TypedParameter<?> tp : p.params.values()) {
TypedParameter x = this.params.get(tp.getName());
TypedParameter<?> x = this.params.get(tp.getName());
if (x == null) {
this.params.put(tp.getName(), tp);
} else if (x.getType() == tp.getType()) {
x.merge(tp);
x.merge(tp.getValue());
}
}
}
Expand Down Expand Up @@ -220,10 +220,12 @@ public boolean isDebug() {
return this.debug.getValue();
}

@SuppressWarnings("unchecked")
public <T> T getParameterDefaultValue(String key, Class<T> type) {
return ((TypedParameter<T>) this.params.get(key)).getDefaultValue();
}

@SuppressWarnings("unchecked")
public <T> T getParameterValue(String key, Class<T> type) {
return ((TypedParameter<T>) this.params.get(key)).getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public TableDefinition getTable() {
return this.columns;
}

public boolean useNullable() {
return this.useNull;
}

public QueryParameters getQueryParameters() {
if (this.queryParams == null) {
this.queryParams = new QueryParameters(this.uri);
Expand Down Expand Up @@ -253,8 +257,6 @@ public static QueryParser fromRequest(RoutingContext ctx, Repository<NamedDataSo

String uri = Objects.requireNonNull(resolver).resolve(req.getParam(PARAM_CONNECTION_STRING));
if (forWrite) {
// boolean useNull =
// Boolean.parseBoolean(req.getParam(PARAM_EXT_TABLE_USE_NULLS));
query = new QueryParser(uri, req.getParam(PARAM_DB_NAME), req.getParam(PARAM_TABLE_NAME),
req.getParam(PARAM_COLUMNS), req.getParam(PARAM_FORMAT_NAME), null, null);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public TypedParameter<T> merge(JsonObject p) {
return this.merge(p, this.name);
}

@SuppressWarnings("unchecked")
public TypedParameter<T> merge(JsonObject p, String name) {
name = name == null ? this.name : name;

Expand Down Expand Up @@ -145,6 +146,7 @@ public TypedParameter<T> merge(Object v) {
return merge(v == null ? (String) null : String.valueOf(v));
}

@SuppressWarnings("unchecked")
public TypedParameter<T> merge(String v) {
if (v != null) {
if (this.type.isAssignableFrom(BigDecimal.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import ru.yandex.clickhouse.jdbcbridge.core.NamedDataSource;
import ru.yandex.clickhouse.jdbcbridge.core.DataType;
import ru.yandex.clickhouse.jdbcbridge.core.DefaultValues;
import ru.yandex.clickhouse.jdbcbridge.core.Extension;
import ru.yandex.clickhouse.jdbcbridge.core.ExtensionManager;
import ru.yandex.clickhouse.jdbcbridge.core.ResponseWriter;
import ru.yandex.clickhouse.jdbcbridge.core.Utils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class DefaultRepositoryManager implements RepositoryManager {
private final List<Repository<? extends ManagedEntity>> repos = Collections.synchronizedList(new ArrayList<>());

@SuppressWarnings("unchecked")
@Override
public <T extends ManagedEntity> Repository<T> getRepository(Class<T> clazz) {
Objects.requireNonNull(clazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public static void initialize(ExtensionManager manager) {
manager.getRepositoryManager().getRepository(NamedDataSource.class).registerType(EXTENSION_NAME, thisExtension);
}

@SuppressWarnings("unchecked")
public static JdbcDataSource newInstance(Object... args) {
if (Objects.requireNonNull(args).length < 2) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class JsonFileRepository<T extends ManagedEntity> extends BaseRepository<T> implements Reloadable {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(JsonFileRepository.class);

@SuppressWarnings("unchecked")
public static <T extends ManagedEntity> JsonFileRepository<T> newInstance(Object... args) {
if (Objects.requireNonNull(args).length < 2) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public static void initialize(ExtensionManager manager) {
dsRepo.registerType(EXTENSION_NAME, thisExtension);
}

@SuppressWarnings("unchecked")
public static ScriptDataSource newInstance(Object... args) {
if (Objects.requireNonNull(args).length < 2) {
throw new IllegalArgumentException(
Expand Down

0 comments on commit cc8a4c0

Please sign in to comment.