Skip to content

Commit 5bb47ed

Browse files
Denzel CodeDenzel Code
authored andcommitted
Specifiable abstraction
1 parent 3cb2adb commit 5bb47ed

File tree

8 files changed

+215
-63
lines changed

8 files changed

+215
-63
lines changed

.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 19 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/advancedsql/query/ExecuteQuery.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
import java.sql.ResultSet;
88
import java.sql.ResultSetMetaData;
99
import java.sql.SQLException;
10+
import java.util.Arrays;
1011
import java.util.HashMap;
1112
import java.util.List;
1213
import java.util.Map;
1314

14-
public abstract class ExecuteQuery<T extends IQuery> extends Query<T> {
15+
public abstract class ExecuteQuery<T extends IQuery> extends Specifiable<T> {
1516

1617
public ExecuteQuery(ITable table) {
1718
super(table);

src/main/java/advancedsql/query/ExecuteUpdate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.sql.PreparedStatement;
66
import java.sql.SQLException;
77

8-
public abstract class ExecuteUpdate<T extends IQuery> extends Query<T> {
8+
public abstract class ExecuteUpdate<T extends IQuery> extends Specifiable<T> {
99

1010
public ExecuteUpdate(ITable table) {
1111
super(table);

src/main/java/advancedsql/query/IQuery.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@
66

77
public interface IQuery {
88

9-
/**
10-
* Specify what values will be affected for example:
11-
* query.where("first_name = ? AND last_name = ?", "Denzel", "Code");
12-
* @param where Where statement.
13-
* @param execute Values of the statement.
14-
* @return Query object.
15-
*/
16-
IQuery where(String where, Object... execute);
17-
18-
/**
19-
* Specify what values will be affected for example:
20-
* query.where("first_name = 'Denzel' AND last_name = 'Code'");
21-
* @param where Where statement.
22-
* @return Query object.
23-
*/
24-
IQuery where(String where);
25-
269
/**
2710
* Execute query and return a boolean.
2811
* Recommended for: CREATE, ALTER, DROP, TRUNCATE.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package advancedsql.query;
2+
3+
public interface ISpecifiable {
4+
5+
/**
6+
* Specify what values will be affected for example:
7+
* query.where("first_name = ? AND last_name = ?", "Denzel", "Code");
8+
* @param where Where statement.
9+
* @param execute Values of the statement.
10+
* @return Query object.
11+
*/
12+
IQuery where(String where, Object... execute);
13+
14+
/**
15+
* Specify what values will be affected for example:
16+
* query.where("first_name = 'Denzel' AND last_name = 'Code'");
17+
* @param where Where statement.
18+
* @return Query object.
19+
*/
20+
IQuery where(String where);
21+
22+
/**
23+
* Assign the limit of rows to be affected.
24+
* @param limit Limit amount.
25+
* @return Query object.
26+
*/
27+
IQuery limit(int limit);
28+
29+
/**
30+
* @return Limit of rows to be affected.
31+
*/
32+
int getLimit();
33+
}

src/main/java/advancedsql/query/Query.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,6 @@ public Query(ITable table) {
3232
this.table = table.getName();
3333
}
3434

35-
/**
36-
* Assign the limit of rows to be affected.
37-
* @param limit Limit amount.
38-
* @return Query object.
39-
*/
40-
public T limit(int limit) {
41-
this.limit = limit;
42-
43-
return (T)this;
44-
}
45-
46-
/**
47-
* @return Limit of rows to be affected.
48-
*/
49-
public int getLimit() {
50-
return this.limit;
51-
}
52-
53-
@Override
54-
public T where(String where) {
55-
this.where = where;
56-
57-
return (T)this;
58-
}
59-
60-
public T where(String where, Object... execute) {
61-
this.execute.addAll(Arrays.asList(execute));
62-
63-
return this.where(where);
64-
}
65-
6635
public Boolean executeStatement() throws SQLException {
6736
prepare = this.sql.prepare(this);
6837

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package advancedsql.query;
2+
3+
import advancedsql.table.ITable;
4+
5+
import java.util.Arrays;
6+
7+
public abstract class Specifiable<T extends IQuery> extends Query<T> implements ISpecifiable {
8+
9+
10+
public Specifiable(ITable table) {
11+
super(table);
12+
}
13+
14+
public T limit(int limit) {
15+
this.limit = limit;
16+
17+
return (T)this;
18+
}
19+
20+
public int getLimit() {
21+
return this.limit;
22+
}
23+
24+
@Override
25+
public T where(String where) {
26+
this.where = where;
27+
28+
return (T)this;
29+
}
30+
31+
public T where(String where, Object... execute) {
32+
this.execute.addAll(Arrays.asList(execute));
33+
34+
return this.where(where);
35+
}
36+
}

0 commit comments

Comments
 (0)