private static void register(Codec<?> codec) {
        List<Class<?>> encodableClasses = codec.getEncodableClasses();
        if (CollectionUtil.isEmpty(encodableClasses)) {
            Class<?> clazz = GenericTypeResolver.resolveTypeArgument(codec.getClass(), Codec.class);
            if (clazz == null) {
                throw new IllegalArgumentException(
                        "The codec with the ID ("
                                + codec.getCodecId()
                                + ") could not be resolved");
            }
            encodableClasses = List.of(clazz);
        }
        for (Class<?> encodableClass : encodableClasses) {
            if (CLASS_TO_CODEC.putIfAbsent(encodableClass, codec) != null) {
                throw new IllegalArgumentException(
                        "The codec for the class ("
                                + encodableClass.getName()
                                + ") has already existed");
            }
        }
        int codecId = codec.getCodecId()
                .getId();
        if (ID_TO_CODEC.putIfAbsent(codecId, codec) != null) {
            throw new IllegalArgumentException(
                    "The codec ID ("
                            + codecId
                            + ") has already existed");
        }
        List<Class<?>> encodableSuperClasses = codec.getEncodableSuperClasses();
        if (CollectionUtil.isNotEmpty(encodableSuperClasses)) {
            for (Class<?> encodableSuperClass : encodableSuperClasses) {
                if (SUPERCLASS_TO_CODEC.putIfAbsent(encodableSuperClass, codec) != null) {
                    throw new IllegalArgumentException(
                            "The codec for the class ("
                                    + encodableSuperClass.getName()
                                    + ") has already existed");
                }
            }
        }
    }
@implNote We don't support something like "instanceof" because of its bad performance.
turms-server-common/src/main/java/im/turms/server/common/infra/cluster/service/codec/codec/CodecPool.java