Skip to content

Commit

Permalink
Remove PrimitiveCodec
Browse files Browse the repository at this point in the history
  • Loading branch information
mirromutth committed Mar 18, 2024
1 parent 2371476 commit d533e1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @param <T> the boxed type of handling primitive data.
*/
abstract class AbstractPrimitiveCodec<T> implements PrimitiveCodec<T> {
abstract class AbstractPrimitiveCodec<T> implements Codec<T> {

private final Class<T> primitiveClass;

Expand All @@ -44,7 +44,6 @@ public final boolean canDecode(MySqlReadableMetadata metadata, Class<?> target)
return (target.isAssignableFrom(boxedClass) || target.equals(primitiveClass)) && doCanDecode(metadata);
}

@Override
public final Class<T> getPrimitiveClass() {
return primitiveClass;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ private DefaultCodecs(List<Codec<?>> codecs) {
fastPath.putIfAbsent(mainClass, codec);
}

if (codec instanceof PrimitiveCodec<?>) {
// Primitive codec must be class-based codec, cannot support ParameterizedType.
PrimitiveCodec<?> c = (PrimitiveCodec<?>) codec;
if (codec instanceof AbstractPrimitiveCodec<?>) {
AbstractPrimitiveCodec<?> c = (AbstractPrimitiveCodec<?>) codec;

fastPath.putIfAbsent(c.getPrimitiveClass(), c);
} else if (codec instanceof ParameterizedCodec<?>) {
Expand Down Expand Up @@ -230,7 +229,7 @@ public MySqlParameter encode(Object value, CodecContext context) {
}

for (Codec<?> codec : codecs) {
if (codec.canEncode(valueToEncode)) {
if (codec != fast && codec.canEncode(valueToEncode)) {
return codec.encode(valueToEncode, context);
}
}
Expand Down Expand Up @@ -293,7 +292,7 @@ private <T> T decodeNormal(NormalFieldValue value, MySqlReadableMetadata metadat
}

for (Codec<?> codec : codecs) {
if (codec.canDecode(metadata, type)) {
if (codec != fast && codec.canDecode(metadata, type)) {
@SuppressWarnings("unchecked")
Codec<T> c = (Codec<T>) codec;
return c.decode(value.getBufferSlice(), metadata, type, binary, context);
Expand Down Expand Up @@ -327,7 +326,7 @@ private <T> T decodeMassive(LargeFieldValue value, MySqlReadableMetadata metadat
}

for (MassiveCodec<?> codec : massiveCodecs) {
if (codec.canDecode(metadata, type)) {
if (codec != fast && codec.canDecode(metadata, type)) {
@SuppressWarnings("unchecked")
MassiveCodec<T> c = (MassiveCodec<T>) codec;
return c.decodeMassive(value.getBufferSlices(), metadata, type, binary, context);
Expand Down

This file was deleted.

0 comments on commit d533e1e

Please sign in to comment.