protected fun getPropertyValues()

in graphql-dgs-codegen-shared-core/src/main/kotlin/com/netflix/graphql/dgs/client/codegen/InputValueSerializer.kt [172:196]


    protected fun getPropertyValues(
        classes: Sequence<KClass<out Any>>,
        input: Any?,
    ): MutableMap<String, Any?> {
        val propertyValues = mutableMapOf<String, Any?>()

        for (klass in classes) {
            for (property in klass.memberProperties) {
                if (property.name in propertyValues || property.isAbstract || property.hasAnnotation<Transient>()) {
                    continue
                }
                property.isAccessible = true
                if (property.returnType.classifier == Optional::class) {
                    val value = property.call(input)
                    if (value != null && value is Optional<*>) {
                        propertyValues[property.name] = value.orElse(null)
                    }
                    // if value is null, don't include the field
                } else {
                    propertyValues[property.name] = property.call(input)
                }
            }
        }
        return propertyValues
    }