Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#467 apply unified style builders for all JDBC integrations
- Loading branch information
Vladimir Buhtoyarov
committed
Mar 25, 2024
1 parent
bc5023a
commit ea1745a
Showing
12 changed files
with
247 additions
and
92 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
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
50 changes: 50 additions & 0 deletions
50
bucket4j-mssql/src/main/java/io/github/bucket4j/mssql/Bucket4jMSSQL.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,50 @@ | ||
package io.github.bucket4j.mssql; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import io.github.bucket4j.distributed.jdbc.AbstractJdbcProxyManagerBuilder; | ||
import io.github.bucket4j.distributed.jdbc.PrimaryKeyMapper; | ||
|
||
/** | ||
* Entry point for MSSQL integration | ||
*/ | ||
public class Bucket4jMSSQL { | ||
|
||
/** | ||
* Returns the builder for {@link MSSQLSelectForUpdateBasedProxyManager} | ||
* | ||
* @param dataSource | ||
* | ||
* @return new instance of {@link MSSQLSelectForUpdateBasedProxyManager} | ||
*/ | ||
public static MSSQLSelectForUpdateBasedProxyManagerBuilder<Long> selectForUpdateBasedBuilder(DataSource dataSource) { | ||
return new MSSQLSelectForUpdateBasedProxyManagerBuilder<>(dataSource, PrimaryKeyMapper.LONG); | ||
} | ||
|
||
public static class MSSQLSelectForUpdateBasedProxyManagerBuilder<K> extends AbstractJdbcProxyManagerBuilder<K, MSSQLSelectForUpdateBasedProxyManager<K>, MSSQLSelectForUpdateBasedProxyManagerBuilder<K>> { | ||
|
||
public MSSQLSelectForUpdateBasedProxyManagerBuilder(DataSource dataSource, PrimaryKeyMapper<K> primaryKeyMapper) { | ||
super(dataSource, primaryKeyMapper); | ||
} | ||
|
||
@Override | ||
public MSSQLSelectForUpdateBasedProxyManager<K> build() { | ||
return new MSSQLSelectForUpdateBasedProxyManager<>(this); | ||
} | ||
|
||
/** | ||
* Specifies the type of primary key. | ||
* | ||
* @param primaryKeyMapper object responsible for setting primary key value in prepared statement. | ||
* | ||
* @return this builder instance | ||
*/ | ||
public <K2> MSSQLSelectForUpdateBasedProxyManagerBuilder<K2> primaryKeyMapper(PrimaryKeyMapper<K2> primaryKeyMapper) { | ||
super.primaryKeyMapper = (PrimaryKeyMapper) Objects.requireNonNull(primaryKeyMapper); | ||
return (MSSQLSelectForUpdateBasedProxyManagerBuilder<K2>) this; | ||
} | ||
} | ||
|
||
} |
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
50 changes: 50 additions & 0 deletions
50
bucket4j-mysql/src/main/java/io/github/bucket4j/mysql/Bucket4jMySQL.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,50 @@ | ||
package io.github.bucket4j.mysql; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import io.github.bucket4j.distributed.jdbc.AbstractJdbcProxyManagerBuilder; | ||
import io.github.bucket4j.distributed.jdbc.PrimaryKeyMapper; | ||
|
||
/** | ||
* Entry point for MySQL integration | ||
*/ | ||
public class Bucket4jMySQL { | ||
|
||
/** | ||
* Returns the builder for {@link MySQLSelectForUpdateBasedProxyManager} | ||
* | ||
* @param dataSource | ||
* | ||
* @return new instance of {@link MySQLSelectForUpdateBasedProxyManager} | ||
*/ | ||
public static MySQLSelectForUpdateBasedProxyManagerBuilder<Long> selectForUpdateBasedBuilder(DataSource dataSource) { | ||
return new MySQLSelectForUpdateBasedProxyManagerBuilder<>(dataSource, PrimaryKeyMapper.LONG); | ||
} | ||
|
||
public static class MySQLSelectForUpdateBasedProxyManagerBuilder<K> extends AbstractJdbcProxyManagerBuilder<K, MySQLSelectForUpdateBasedProxyManager<K>, MySQLSelectForUpdateBasedProxyManagerBuilder<K>> { | ||
|
||
public MySQLSelectForUpdateBasedProxyManagerBuilder(DataSource dataSource, PrimaryKeyMapper<K> primaryKeyMapper) { | ||
super(dataSource, primaryKeyMapper); | ||
} | ||
|
||
@Override | ||
public MySQLSelectForUpdateBasedProxyManager<K> build() { | ||
return new MySQLSelectForUpdateBasedProxyManager<>(this); | ||
} | ||
|
||
/** | ||
* Specifies the type of primary key. | ||
* | ||
* @param primaryKeyMapper object responsible for setting primary key value in prepared statement. | ||
* | ||
* @return this builder instance | ||
*/ | ||
public <K2> MySQLSelectForUpdateBasedProxyManagerBuilder<K2> primaryKeyMapper(PrimaryKeyMapper<K2> primaryKeyMapper) { | ||
super.primaryKeyMapper = (PrimaryKeyMapper) Objects.requireNonNull(primaryKeyMapper); | ||
return (MySQLSelectForUpdateBasedProxyManagerBuilder<K2>) this; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.