Skip to content

Commit

Permalink
#1: Extract 'AbstractQuery' to top level class.
Browse files Browse the repository at this point in the history
  • Loading branch information
jenetics committed Jan 5, 2017
1 parent 021c198 commit e3a5304
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 19 deletions.
46 changes: 46 additions & 0 deletions jpx.jdbc/src/main/java/io/jenetics/jpx/jdbc/AbstractQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Java GPX Library (@__identifier__@).
* Copyright (c) @__year__@ Franz Wilhelmstötter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author:
* Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
*/
package io.jenetics.jpx.jdbc;

import static java.util.Objects.requireNonNull;

import java.sql.Connection;

/**
* Abstract query class.
*
* @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
* @version !__version__!
* @since !__version__!
*/
abstract class AbstractQuery {
final Connection _conn;
final PreparedQuery _query;

AbstractQuery(final Connection conn, final PreparedQuery query) {
_conn = requireNonNull(conn);
_query = requireNonNull(query);
}

AbstractQuery(final Connection conn, final String query) {
this(conn, PreparedQuery.parse(query));
}

}
20 changes: 1 addition & 19 deletions jpx.jdbc/src/main/java/io/jenetics/jpx/jdbc/DAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,10 @@ public static <T> Param insert(
}
}

/**
* Abstract query class.
*/
static abstract class Query {
final Connection _conn;
final PreparedQuery _query;

Query(final Connection conn, final PreparedQuery query) {
_conn = requireNonNull(conn);
_query = requireNonNull(query);
}

Query(final Connection conn, final String query) {
this(conn, PreparedQuery.parse(query));
}

}

/**
* Represents a select SQL query.
*/
public static final class SQLQuery extends Query {
public static final class SQLQuery extends AbstractQuery {
private final List<Param> _params = new ArrayList<>();

public SQLQuery(final Connection conn, final PreparedQuery query) {
Expand Down

0 comments on commit e3a5304

Please sign in to comment.