-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#115] Refactor BatchResult & BatchReturningResult
- Loading branch information
Showing
9 changed files
with
77 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
core/src/main/java/io/github/zero88/jooqx/BatchResultImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.github.zero88.jooqx; | ||
|
||
class BatchResultImpl implements BatchResult { | ||
|
||
private final int total; | ||
private final int successes; | ||
|
||
BatchResultImpl(int total, int successes) { | ||
this.total = total; | ||
this.successes = successes; | ||
} | ||
|
||
@Override | ||
public int getTotal() { return total; } | ||
|
||
@Override | ||
public int getSuccesses() { return successes; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/src/main/java/io/github/zero88/jooqx/BatchReturningResultImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.zero88.jooqx; | ||
|
||
import java.util.List; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
final class BatchReturningResultImpl<R> extends BatchResultImpl implements BatchReturningResult<R> { | ||
|
||
@NotNull | ||
private final List<R> records; | ||
|
||
BatchReturningResultImpl(int total, @NotNull List<R> rs) { | ||
super(total, rs.size()); | ||
this.records = rs; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<R> getRecords() { return records; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/src/main/java/io/github/zero88/jooqx/JsonRecordImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.zero88.jooqx; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.jooq.Table; | ||
import org.jooq.TableRecord; | ||
import org.jooq.impl.CustomRecord; | ||
|
||
import io.vertx.core.json.JsonObject; | ||
|
||
final class JsonRecordImpl<R extends TableRecord<R>> extends CustomRecord<R> implements JsonRecord<R> { | ||
|
||
JsonRecordImpl(Table<R> table) { | ||
super(table); | ||
} | ||
|
||
public JsonObject toJson() { | ||
final JsonObject json = new JsonObject(); | ||
Arrays.stream(this.fields()).forEach(f -> json.put(f.getName(), f.get(this))); | ||
return json; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.