@Override
    public Stream<MappingField> resolveAndValidateFields(
            boolean isKey,
            List<MappingField> userFields,
            Map<String, String> options,
            InternalSerializationService serializationService
    ) {
        Map<QueryPath, MappingField> fieldsByPath = extractFields(userFields, isKey);

        Class<?> typeClass = getMetadata(fieldsByPath)
                .<Class<?>>map(KvMetadataJavaResolver::loadClass)
                .orElseGet(() -> loadClass(options, isKey));
        QueryDataType type = QueryDataTypeUtils.resolveTypeForClass(typeClass);

        if (type.getTypeFamily() != QueryDataTypeFamily.OBJECT || type.isCustomType()) {
            return userFields.isEmpty()
                    ? resolvePrimitiveField(isKey, type)
                    : resolveAndValidatePrimitiveField(isKey, fieldsByPath, type);
        } else {
            return userFields.isEmpty()
                    ? resolveObjectFields(isKey, typeClass)
                    : resolveAndValidateObjectFields(isKey, fieldsByPath, typeClass);
        }
    }
@Test
    @Parameters({
            "true, __key",
            "false, this"
    })
    public void test_resolvePrimitiveField(boolean key, String path) {
        Map<String, String> options = Map.of(
                (key ? OPTION_KEY_FORMAT : OPTION_VALUE_FORMAT), JAVA_FORMAT,
                (key ? OPTION_KEY_CLASS : OPTION_VALUE_CLASS), int.class.getName()
        );

        Stream<MappingField> fields = INSTANCE.resolveAndValidateFields(key, emptyList(), options, null);

        assertThat(fields).containsExactly(field(path, QueryDataType.INT, QueryPath.create(path).toString()));
    }