Skip to content

Commit

Permalink
refactor(database): optimize imports and update Pair references
Browse files Browse the repository at this point in the history
- Simplify import statements for Pair class in DatabaseWrapper and Database
- Update method parameters to use the library's Pair class
  • Loading branch information
GeorgeV220 committed Mar 18, 2024
1 parent 1b2d557 commit e6c2037
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.georgev22.library.database.sql.sqlite.SQLite;
import com.georgev22.library.maps.ObjectMap;
import com.georgev22.library.maps.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -212,12 +213,12 @@ public boolean renameTable(@NotNull String oldTableName, @NotNull String newTabl
* @throws SQLException if a database access error occurs
* @throws ClassNotFoundException if the specified database driver class cannot be found
*/
public void createTable(@NotNull String tableName, @NotNull ObjectMap<String, ObjectMap.Pair<String, String>> columnsMap) throws SQLException, ClassNotFoundException {
public void createTable(@NotNull String tableName, @NotNull ObjectMap<String, Pair<String, String>> columnsMap) throws SQLException, ClassNotFoundException {
StringBuilder queryBuilder = new StringBuilder("CREATE TABLE IF NOT EXISTS `" + tableName + "` (");

for (Map.Entry<String, ObjectMap.Pair<String, String>> entry : columnsMap.entrySet()) {
for (Map.Entry<String, Pair<String, String>> entry : columnsMap.entrySet()) {
String columnName = entry.getKey();
ObjectMap.Pair<String, String> columnDetails = entry.getValue();
Pair<String, String> columnDetails = entry.getValue();
String columnType = columnDetails.key();
String defaultValue = columnDetails.value();

Expand Down Expand Up @@ -300,8 +301,8 @@ public String buildUpdateStatement(String tableName, Map<String, Object> columnV
/**
* Builds an SQL DELETE statement for the specified table name, column values, and condition.
*
* @param tableName the name of the table
* @param condition the condition to apply for deleting the rows
* @param tableName the name of the table
* @param condition the condition to apply for deleting the rows
* @return the SQL DELETE statement
*/
public String buildDeleteStatement(String tableName, String condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.georgev22.library.database.sql.sqlite.SQLite;
import com.georgev22.library.maps.HashObjectMap;
import com.georgev22.library.maps.ObjectMap;
import com.georgev22.library.maps.ObjectMap.Pair;
import com.georgev22.library.maps.Pair;
import com.georgev22.library.utilities.Utils;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoClient;
Expand Down

0 comments on commit e6c2037

Please sign in to comment.