-
Notifications
You must be signed in to change notification settings - Fork 278
/
Bucket4jMariaDB.java
50 lines (40 loc) · 1.85 KB
/
Bucket4jMariaDB.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package io.github.bucket4j.mariadb;
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 MariaDB integration
*/
public class Bucket4jMariaDB {
/**
* Returns the builder for {@link MariaDBSelectForUpdateBasedProxyManager}
*
* @param dataSource
*
* @return new instance of {@link MariaDBSelectForUpdateBasedProxyManager}
*/
public static MariaDBSelectForUpdateBasedProxyManagerBuilder<Long> selectForUpdateBasedBuilder(DataSource dataSource) {
return new MariaDBSelectForUpdateBasedProxyManagerBuilder<>(dataSource, PrimaryKeyMapper.LONG);
}
public static class MariaDBSelectForUpdateBasedProxyManagerBuilder<K> extends AbstractJdbcProxyManagerBuilder<K, MariaDBSelectForUpdateBasedProxyManager<K>, MariaDBSelectForUpdateBasedProxyManagerBuilder<K>> {
public MariaDBSelectForUpdateBasedProxyManagerBuilder(DataSource dataSource, PrimaryKeyMapper<K> primaryKeyMapper) {
super(dataSource, primaryKeyMapper);
}
@Override
public MariaDBSelectForUpdateBasedProxyManager<K> build() {
return new MariaDBSelectForUpdateBasedProxyManager<>(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> MariaDBSelectForUpdateBasedProxyManagerBuilder<K2> primaryKeyMapper(PrimaryKeyMapper<K2> primaryKeyMapper) {
super.primaryKeyMapper = (PrimaryKeyMapper) Objects.requireNonNull(primaryKeyMapper);
return (MariaDBSelectForUpdateBasedProxyManagerBuilder<K2>) this;
}
}
}