Skip to content

Commit d9ac068

Browse files
committed
refactor: hide mutable primitive codec array
Keep PRIMITIVE_CODECS public for source and binary compatibility, deprecate direct array access, and add getPrimitiveCodecs() as the immutable-list accessor. Refs #908
1 parent 4cd0be3 commit d9ac068

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/CodecRegistryConstants.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
2121
import com.datastax.oss.driver.api.core.type.codec.TypeCodecs;
22+
import java.util.List;
2223
import java.util.function.BiConsumer;
2324
import java.util.function.BiFunction;
2425

@@ -31,7 +32,12 @@ public class CodecRegistryConstants {
3132
* <p>This is exposed in case you want to call {@link
3233
* DefaultCodecRegistry#DefaultCodecRegistry(String, int, BiFunction, int, BiConsumer,
3334
* TypeCodec[])} but only customize the caching options.
35+
*
36+
* @deprecated use {@link #getPrimitiveCodecs()} instead. This array remains public for binary
37+
* compatibility and will be made non-public in a future release.
3438
*/
39+
@Deprecated
40+
@SuppressWarnings("MutablePublicArray")
3541
public static final TypeCodec<?>[] PRIMITIVE_CODECS =
3642
new TypeCodec<?>[] {
3743
// Must be declared before AsciiCodec so it gets chosen when CQL type not available
@@ -57,4 +63,12 @@ public class CodecRegistryConstants {
5763
TypeCodecs.COUNTER,
5864
TypeCodecs.ASCII
5965
};
66+
67+
/**
68+
* Returns the driver's default primitive codecs (map all primitive CQL types to their "natural"
69+
* Java equivalent).
70+
*/
71+
public static List<TypeCodec<?>> getPrimitiveCodecs() {
72+
return List.of(PRIMITIVE_CODECS);
73+
}
6074
}

0 commit comments

Comments
 (0)