diff --git a/.github/DEPEND.md b/.github/DEPEND.md
index df875b1..64cdac6 100644
--- a/.github/DEPEND.md
+++ b/.github/DEPEND.md
@@ -1,6 +1,5 @@
## | `Wonsi - Add as depend:`
-[![Clojars Project](https://img.shields.io/clojars/v/io.github.dynomake/wonsi.svg)](https://clojars.org/io.github.dynomake/wonsi)
Here is how to add this framework depending on your project.
### | `Gradle`:
@@ -9,14 +8,14 @@ If you use Gradle with Groovy, then here is an example of adding dependencies:
repositories {
// other repositories
maven {
- name = "clojars.org"
- url = uri("https://repo.clojars.org")
+ name = "dynomakeRepo"
+ url = uri("https://maven.dynomake.space/releases")
}
}
dependencies {
// other depends
- implementation 'io.github.dynomake:wonsi:VERSION'
+ implementation 'io.github.dynomake:wonsi:1.0.7'
}
```
@@ -26,8 +25,8 @@ Repository:
```xml
- clojars.org
- https://repo.clojars.org
+ dynomake-repo
+ https://maven.dynomake.space/releases
```
@@ -38,6 +37,6 @@ Depend:
io.github.dynomake
wonsi
- VERSION
+ 1.0.7
```
\ No newline at end of file
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 6581a89..7c57a95 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -23,7 +23,7 @@ jobs:
- name: Build and Publish
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
env:
- deployUser: ${{ secrets.CLOJARS_USER }}
- deployToken: ${{ secrets.CLOJARS_TOKEN }}
+ deployUser: ${{ secrets.MAVEN_USER }}
+ deployToken: ${{ secrets.MAVEN_TOKEN }}
with:
arguments: publish
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index f8e40b5..2cb284b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,7 +4,7 @@ plugins {
}
group 'io.github.dynomake'
-version '1.0.6'
+version '1.0.7'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
@@ -28,8 +28,9 @@ dependencies {
publishing {
repositories {
maven {
- name = "clojars"
- url = uri("https://clojars.org/repo")
+ name = "dynomakeRepoReleases"
+ url = uri("https://maven.dynomake.space/releases")
+
credentials {
username = "$System.env.deployUser"
password = "$System.env.deployToken"
diff --git a/src/main/java/net/wonsi/api/Wonsi.java b/src/main/java/net/wonsi/api/Wonsi.java
index b5513ad..36d77d0 100644
--- a/src/main/java/net/wonsi/api/Wonsi.java
+++ b/src/main/java/net/wonsi/api/Wonsi.java
@@ -30,4 +30,24 @@ public interface Wonsi {
* @return - wonsi table handle
*/
WonsiTable getTable(@NonNull Class tClass);
+
+
+ /**
+ * Get or create (if not exits) table by class and name
+ *
+ * @param tClass - class
+ * @return - wonsi table handle
+ */
+ WonsiTable getTable(@NonNull Class tClass, @NonNull Function deserializer, @NonNull String tableName);
+
+
+ /**
+ * Get or create (if not exits) table by class
+ * if you are using this way with auto-serialisation & de, you can
+ * use only long number types. DO NOT USE Long, int, short, Integer.
+ *
+ * @param tClass - class
+ * @return - wonsi table handle
+ */
+ WonsiTable getTable(@NonNull Class tClass, @NonNull String tableName);
}
diff --git a/src/main/java/net/wonsi/proxy/RealWonsi.java b/src/main/java/net/wonsi/proxy/RealWonsi.java
index 699c5e2..9abcf07 100644
--- a/src/main/java/net/wonsi/proxy/RealWonsi.java
+++ b/src/main/java/net/wonsi/proxy/RealWonsi.java
@@ -24,18 +24,31 @@ public class RealWonsi implements Wonsi {
public WonsiTable getTable(@NonNull Class tClass, @NonNull Function deserializer) {
Table tableAnnotation = tClass.getAnnotation(Table.class);
- if (tableAnnotation == null) throw new IllegalArgumentException("Class don't has annotation @Table, please read documentation!");
+ if (tableAnnotation == null)
+ throw new IllegalArgumentException("Class don't has annotation @Table, please read documentation!");
+ return getTable(tClass, deserializer, tableAnnotation.value());
+ }
- WonsiTable table = new RealWonsiTable<>(connection, deserializer, tableAnnotation.value());
- table.createIfNotExits(tClass);
+ @Override
+ public WonsiTable getTable(@NonNull Class tClass) {
+ return getTable(tClass, createDeserializer(tClass));
+ }
+ @Override
+ public WonsiTable getTable(@NonNull Class tClass, @NonNull Function deserializer, @NonNull String tableName) {
+ WonsiTable table = new RealWonsiTable<>(connection, deserializer, tableName);
+ table.createIfNotExits(tClass);
return table;
}
@Override
- public WonsiTable getTable(@NonNull Class tClass) {
- return getTable(tClass, (resultSet) -> {
+ public WonsiTable getTable(@NonNull Class tClass, @NonNull String tableName) {
+ return getTable(tClass, createDeserializer(tClass), tableName);
+ }
+
+ private Function createDeserializer(@NonNull Class tClass) {
+ return (resultSet) -> {
try {
T object = tClass.newInstance();
@@ -47,7 +60,7 @@ public WonsiTable getTable(@NonNull Class tClass) {
// field.getType().cast(
field.set(object, value.getClass().isAssignableFrom(field.getType()) ? value :
value.getClass().equals(Long.class) ? (((Long) value).longValue()) :
- field.getType().cast(value));
+ field.getType().cast(value));
}
return object;
@@ -55,7 +68,6 @@ public WonsiTable getTable(@NonNull Class tClass) {
exception.printStackTrace();
return null;
}
- });
+ };
}
-
}