Skip to content

Commit

Permalink
Consistent spelling style
Browse files Browse the repository at this point in the history
  • Loading branch information
mirromutth committed Mar 15, 2024
1 parent 39e55e2 commit 3e70b4a
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 82 deletions.
6 changes: 3 additions & 3 deletions r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Binding.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import java.util.Arrays;

/**
* A collection of {@link MySqlParameter} for one bind invocation of a parametrized statement.
* A collection of {@link MySqlParameter} for one bind invocation of a parameterized statement.
*
* @see ParametrizedStatementSupport
* @see ParameterizedStatementSupport
*/
final class Binding {

Expand All @@ -40,7 +40,7 @@ final class Binding {
* Add a {@link MySqlParameter} to the binding.
*
* @param index the index of the {@link MySqlParameter}
* @param value the {@link MySqlParameter} from {@link PrepareParametrizedStatement}
* @param value the {@link MySqlParameter} from {@link PrepareParameterizedStatement}
*/
void add(int index, MySqlParameter value) {
if (index < 0 || index >= this.values.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ public Builder tcpNoDelay(boolean enabled) {
}

/**
* Configures the protocol of parametrized statements to the text protocol.
* Configures the protocol of parameterized statements to the text protocol.
* <p>
* The text protocol is default protocol that's using client-preparing. See also MySQL
* documentations.
Expand All @@ -897,7 +897,7 @@ public Builder useClientPrepareStatement() {
}

/**
* Configures the protocol of parametrized statements to the binary protocol.
* Configures the protocol of parameterized statements to the binary protocol.
* <p>
* The binary protocol is compact protocol that's using server-preparing. See also MySQL
* documentations.
Expand All @@ -910,7 +910,7 @@ public Builder useServerPrepareStatement() {
}

/**
* Configures the protocol of parametrized statements and prepare-preferred simple statements to the
* Configures the protocol of parameterized statements and prepare-preferred simple statements to the
* binary protocol.
* <p>
* The {@code preferPrepareStatement} configures whether to prefer prepare execution on a
Expand Down Expand Up @@ -1025,7 +1025,7 @@ public Builder queryCacheSize(int queryCacheSize) {
/**
* Configures the maximum size of the server-preparing cache. Usually it should be power of two.
* Default to {@code 256}. Driver will use unbounded cache if size is less than {@code 0}. It is used
* only if using server-preparing parametrized statements, i.e. the {@link #useServerPrepareStatement}
* only if using server-preparing parameterized statements, i.e. the {@link #useServerPrepareStatement}
* is set.
* <p>
* Notice: the cache is using EC model (the PACELC theorem) for ensure consistency. Consistency is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ public final class MySqlConnectionFactoryProvider implements ConnectionFactoryPr
Option.valueOf("createDatabaseIfNotExist");

/**
* Enable server preparing for parametrized statements and prefer server preparing simple statements.
* Enable server preparing for parameterized statements and prefer server preparing simple statements.
* <p>
* The value can be a {@link Boolean}. If it is {@code true}, driver will use server preparing for
* parametrized statements and text query for simple statements. If it is {@code false}, driver will use
* client preparing for parametrized statements and text query for simple statements.
* parameterized statements and text query for simple statements. If it is {@code false}, driver will use
* client preparing for parameterized statements and text query for simple statements.
* <p>
* The value can be a {@link Predicate}{@code <}{@link String}{@code >}. If it is set, driver will server
* preparing for parametrized statements, it configures whether to prefer prepare execution on a
* preparing for parameterized statements, it configures whether to prefer prepare execution on a
* statement-by-statement basis (simple statements). The {@link Predicate}{@code <}{@link String}{@code >}
* accepts the simple SQL query string and returns a {@code boolean} flag indicating preference.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ public MySqlStatement createStatement(String sql) {
}

if (prepare == null) {
logger.debug("Create a parametrized statement provided by text query");
return new TextParametrizedStatement(client, codecs, query);
logger.debug("Create a parameterized statement provided by text query");
return new TextParameterizedStatement(client, codecs, query);
}

logger.debug("Create a parametrized statement provided by prepare query");
logger.debug("Create a parameterized statement provided by prepare query");

return new PrepareParametrizedStatement(client, codecs, query, prepareCache);
return new PrepareParameterizedStatement(client, codecs, query, prepareCache);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.nio.ByteBuffer;

/**
* A writer for {@link MySqlParameter}s of parametrized statements with text-based protocol.
* A writer for {@link MySqlParameter}s of parameterized statements with text-based protocol.
*/
public abstract class ParameterWriter extends Writer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import static io.asyncer.r2dbc.mysql.internal.util.AssertUtils.requireNonNull;

/**
* Base class considers parametrized {@link MySqlStatement} with parameter markers.
* Base class considers parameterized {@link MySqlStatement} with parameter markers.
* <p>
* MySQL uses indexed parameters which are marked by {@literal ?} without naming. Implementations should use
* {@link Query} to supports named parameters.
*/
abstract class ParametrizedStatementSupport extends MySqlStatementSupport {
abstract class ParameterizedStatementSupport extends MySqlStatementSupport {

protected final Codecs codecs;

Expand All @@ -49,7 +49,7 @@ abstract class ParametrizedStatementSupport extends MySqlStatementSupport {

private final AtomicBoolean executed = new AtomicBoolean();

ParametrizedStatementSupport(Client client, Codecs codecs, Query query) {
ParameterizedStatementSupport(Client client, Codecs codecs, Query query) {
super(client);

requireNonNull(query, "query must not be null");
Expand Down Expand Up @@ -113,7 +113,7 @@ public final Flux<? extends MySqlResult> execute() {

return Flux.defer(() -> {
if (!executed.compareAndSet(false, true)) {
return Flux.error(new IllegalStateException("Parametrized statement was already executed"));
return Flux.error(new IllegalStateException("Parameterized statement was already executed"));
}

return execute(bindings.bindings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import static io.asyncer.r2dbc.mysql.internal.util.AssertUtils.require;

/**
* An implementation of {@link ParametrizedStatementSupport} based on MySQL prepare query.
* An implementation of {@link ParameterizedStatementSupport} based on MySQL prepare query.
*/
final class PrepareParametrizedStatement extends ParametrizedStatementSupport {
final class PrepareParameterizedStatement extends ParameterizedStatementSupport {

private final PrepareCache prepareCache;

private int fetchSize = 0;

PrepareParametrizedStatement(Client client, Codecs codecs, Query query, PrepareCache prepareCache) {
PrepareParameterizedStatement(Client client, Codecs codecs, Query query, PrepareCache prepareCache) {
super(client, codecs, query);
this.prepareCache = prepareCache;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
import java.util.function.Predicate;

/**
* A message flow considers both of parametrized and text queries, such as {@link TextParametrizedStatement},
* {@link PrepareParametrizedStatement}, {@link TextSimpleStatement}, {@link PrepareSimpleStatement} and
* A message flow considers both of parameterized and text queries, such as {@link TextParameterizedStatement},
* {@link PrepareParameterizedStatement}, {@link TextSimpleStatement}, {@link PrepareSimpleStatement} and
* {@link MySqlBatch}.
*/
final class QueryFlow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import java.util.List;

/**
* An implementation of {@link ParametrizedStatementSupport} based on MySQL text query.
* An implementation of {@link ParameterizedStatementSupport} based on MySQL text query.
*/
final class TextParametrizedStatement extends ParametrizedStatementSupport {
final class TextParameterizedStatement extends ParameterizedStatementSupport {

TextParametrizedStatement(Client client, Codecs codecs, Query query) {
TextParameterizedStatement(Client client, Codecs codecs, Query query) {
super(client, codecs, query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface MySqlStatement extends Statement {
* {@inheritDoc}
*
* @return {@link MySqlStatement this}
* @throws IllegalStateException if the statement is parametrized and not all parameters are provided
* @throws IllegalStateException if the statement is parameterized and not all parameters are provided
*/
@Override
MySqlStatement add();
Expand Down Expand Up @@ -96,7 +96,7 @@ public interface MySqlStatement extends Statement {
* {@inheritDoc}
*
* @return a {@link Flux} representing {@link MySqlResult}s of the statement
* @throws IllegalStateException if the statement is parametrized and not all parameters are provided
* @throws IllegalStateException if the statement is parameterized and not all parameters are provided
*/
@Override
Flux<? extends MySqlResult> execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Codec to encode and decode values based on MySQL data binary/text protocol.
* <p>
* Use {@link ParametrizedCodec} for support {@code ParameterizedType} encoding/decoding.
* Use {@link ParameterizedCodec} for support {@code ParameterizedType} encoding/decoding.
*
* @param <T> the type that is handled by this codec.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,44 @@ final class DefaultCodecs implements Codecs {

private final Codec<?>[] codecs;

private final ParametrizedCodec<?>[] parametrizedCodecs;
private final ParameterizedCodec<?>[] parameterizedCodecs;

private final MassiveCodec<?>[] massiveCodecs;

private final MassiveParametrizedCodec<?>[] massiveParametrizedCodecs;
private final MassiveParameterizedCodec<?>[] massiveParameterizedCodecs;

private final Map<Type, PrimitiveCodec<?>> primitiveCodecs;

private DefaultCodecs(Codec<?>[] codecs) {
this.codecs = requireNonNull(codecs, "codecs must not be null");

Map<Type, PrimitiveCodec<?>> primitiveCodecs = new HashMap<>();
List<ParametrizedCodec<?>> parametrizedCodecs = new ArrayList<>();
List<ParameterizedCodec<?>> parameterizedCodecs = new ArrayList<>();
List<MassiveCodec<?>> massiveCodecs = new ArrayList<>();
List<MassiveParametrizedCodec<?>> massiveParamCodecs = new ArrayList<>();
List<MassiveParameterizedCodec<?>> massiveParamCodecs = new ArrayList<>();

for (Codec<?> codec : codecs) {
if (codec instanceof PrimitiveCodec<?>) {
// Primitive codec must be class-based codec, cannot support ParameterizedType.
PrimitiveCodec<?> c = (PrimitiveCodec<?>) codec;
primitiveCodecs.put(c.getPrimitiveClass(), c);
} else if (codec instanceof ParametrizedCodec<?>) {
parametrizedCodecs.add((ParametrizedCodec<?>) codec);
} else if (codec instanceof ParameterizedCodec<?>) {
parameterizedCodecs.add((ParameterizedCodec<?>) codec);
}

if (codec instanceof MassiveCodec<?>) {
massiveCodecs.add((MassiveCodec<?>) codec);

if (codec instanceof MassiveParametrizedCodec<?>) {
massiveParamCodecs.add((MassiveParametrizedCodec<?>) codec);
if (codec instanceof MassiveParameterizedCodec<?>) {
massiveParamCodecs.add((MassiveParameterizedCodec<?>) codec);
}
}
}

this.primitiveCodecs = primitiveCodecs;
this.massiveCodecs = massiveCodecs.toArray(new MassiveCodec<?>[0]);
this.massiveParametrizedCodecs = massiveParamCodecs.toArray(new MassiveParametrizedCodec<?>[0]);
this.parametrizedCodecs = parametrizedCodecs.toArray(new ParametrizedCodec<?>[0]);
this.massiveParameterizedCodecs = massiveParamCodecs.toArray(new MassiveParameterizedCodec<?>[0]);
this.parameterizedCodecs = parameterizedCodecs.toArray(new ParameterizedCodec<?>[0]);
}

/**
Expand Down Expand Up @@ -230,7 +230,7 @@ private <T> T decodeNormal(NormalFieldValue value, MySqlReadableMetadata metadat
@Nullable
private <T> T decodeNormal(NormalFieldValue value, MySqlReadableMetadata metadata, ParameterizedType type,
boolean binary, CodecContext context) {
for (ParametrizedCodec<?> codec : parametrizedCodecs) {
for (ParameterizedCodec<?> codec : parameterizedCodecs) {
if (codec.canDecode(metadata, type)) {
@SuppressWarnings("unchecked")
T result = (T) codec.decode(value.getBufferSlice(), metadata, type, binary, context);
Expand Down Expand Up @@ -258,7 +258,7 @@ private <T> T decodeMassive(LargeFieldValue value, MySqlReadableMetadata metadat
@Nullable
private <T> T decodeMassive(LargeFieldValue value, MySqlReadableMetadata metadata, ParameterizedType type,
boolean binary, CodecContext context) {
for (MassiveParametrizedCodec<?> codec : massiveParametrizedCodecs) {
for (MassiveParameterizedCodec<?> codec : massiveParameterizedCodecs) {
if (codec.canDecode(metadata, type)) {
@SuppressWarnings("unchecked")
T result = (T) codec.decodeMassive(value.getBufferSlices(), metadata, type, binary, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* <p>
* For now, supports only A.D. calendar in {@link ChronoLocalDateTime}.
*/
final class LocalDateTimeCodec implements ParametrizedCodec<LocalDateTime> {
final class LocalDateTimeCodec implements ParameterizedCodec<LocalDateTime> {

static final LocalDateTimeCodec INSTANCE = new LocalDateTimeCodec();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @param <T> the type that is handled by this codec.
*/
public interface MassiveParametrizedCodec<T> extends ParametrizedCodec<T>, MassiveCodec<T> {
public interface MassiveParameterizedCodec<T> extends ParameterizedCodec<T>, MassiveCodec<T> {

/**
* Decode a massive value as specified {@link ParameterizedType}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @param <T> the type without parameter that is handled by this codec.
*/
public interface ParametrizedCodec<T> extends Codec<T> {
public interface ParameterizedCodec<T> extends Codec<T> {

/**
* Decodes a {@link ByteBuf} as specified {@link ParameterizedType}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* Codec for {@link Set}{@code <}{@link String}{@code >}, {@link Set}{@code <}{@link Enum}{@code >} and the
* {@link String}{@code []}.
*/
final class SetCodec implements ParametrizedCodec<String[]> {
final class SetCodec implements ParameterizedCodec<String[]> {

static final SetCodec INSTANCE = new SetCodec();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* <p>
* For now, supports only A.D. calendar in {@link ChronoZonedDateTime}.
*/
final class ZonedDateTimeCodec implements ParametrizedCodec<ZonedDateTime> {
final class ZonedDateTimeCodec implements ParameterizedCodec<ZonedDateTime> {

static final ZonedDateTimeCodec INSTANCE = new ZonedDateTimeCodec();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,28 @@ void createStatement() {
assertThat(noPrepare.createStatement(condition))
.isExactlyInstanceOf(TextSimpleStatement.class);
assertThat(noPrepare.createStatement("SELECT * FROM test WHERE id=?"))
.isExactlyInstanceOf(TextParametrizedStatement.class);
.isExactlyInstanceOf(TextParameterizedStatement.class);

assertThat(allPrepare.createStatement("SELECT * FROM test WHERE id=1"))
.isExactlyInstanceOf(PrepareSimpleStatement.class);
assertThat(allPrepare.createStatement(condition))
.isExactlyInstanceOf(PrepareSimpleStatement.class);
assertThat(allPrepare.createStatement("SELECT * FROM test WHERE id=?"))
.isExactlyInstanceOf(PrepareParametrizedStatement.class);
.isExactlyInstanceOf(PrepareParameterizedStatement.class);

assertThat(halfPrepare.createStatement("SELECT * FROM test WHERE id=1"))
.isExactlyInstanceOf(TextSimpleStatement.class);
assertThat(halfPrepare.createStatement(condition))
.isExactlyInstanceOf(TextSimpleStatement.class);
assertThat(halfPrepare.createStatement("SELECT * FROM test WHERE id=?"))
.isExactlyInstanceOf(PrepareParametrizedStatement.class);
.isExactlyInstanceOf(PrepareParameterizedStatement.class);

assertThat(conditionPrepare.createStatement("SELECT * FROM test WHERE id=1"))
.isExactlyInstanceOf(TextSimpleStatement.class);
assertThat(conditionPrepare.createStatement(condition))
.isExactlyInstanceOf(PrepareSimpleStatement.class);
assertThat(conditionPrepare.createStatement("SELECT * FROM test WHERE id=?"))
.isExactlyInstanceOf(PrepareParametrizedStatement.class);
.isExactlyInstanceOf(PrepareParameterizedStatement.class);
}

@SuppressWarnings("ConstantConditions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@
import static org.mockito.Mockito.when;

/**
* Unit tests for {@link PrepareParametrizedStatement}.
* Unit tests for {@link PrepareParameterizedStatement}.
*/
class PrepareParametrizedStatementTest implements StatementTestSupport<PrepareParametrizedStatement> {
class PrepareParameterizedStatementTest implements StatementTestSupport<PrepareParameterizedStatement> {

private final Codecs codecs = Codecs.builder().build();

private final Field fetchSize = PrepareParametrizedStatement.class.getDeclaredField("fetchSize");
private final Field fetchSize = PrepareParameterizedStatement.class.getDeclaredField("fetchSize");

PrepareParametrizedStatementTest() throws NoSuchFieldException {
PrepareParameterizedStatementTest() throws NoSuchFieldException {
fetchSize.setAccessible(true);
}

@Override
public int getFetchSize(PrepareParametrizedStatement statement) throws IllegalAccessException {
public int getFetchSize(PrepareParameterizedStatement statement) throws IllegalAccessException {
return fetchSize.getInt(statement);
}

@Override
public PrepareParametrizedStatement makeInstance(boolean isMariaDB, String sql, String ignored) {
public PrepareParameterizedStatement makeInstance(boolean isMariaDB, String sql, String ignored) {
Client client = mock(Client.class);

when(client.getContext()).thenReturn(ConnectionContextTest.mock(isMariaDB));

return new PrepareParametrizedStatement(
return new PrepareParameterizedStatement(
client,
codecs,
Query.parse(sql),
Expand Down
Loading

0 comments on commit 3e70b4a

Please sign in to comment.