Skip to content

Commit 93ee844

Browse files
committed
feat: AbstractInputDataClassGenerator: implement ability to override name of the "buildByMap" method
1 parent 3b47ce8 commit 93ee844

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

graphql-kotlin-toolkit-codegen/src/main/kotlin/com/auritylab/graphql/kotlin/toolkit/codegen/generator/AbstractInputDataClassGenerator.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.squareup.kotlinpoet.FileSpec
1010
import com.squareup.kotlinpoet.FunSpec
1111
import com.squareup.kotlinpoet.KModifier
1212
import com.squareup.kotlinpoet.MAP
13+
import com.squareup.kotlinpoet.MemberName
1314
import com.squareup.kotlinpoet.ParameterSpec
1415
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
1516
import com.squareup.kotlinpoet.PropertySpec
@@ -34,6 +35,9 @@ internal abstract class AbstractInputDataClassGenerator(
3435

3536
protected abstract val dataProperties: List<DataProperty>
3637

38+
protected open val buildByMapMemberName: MemberName
39+
get() = MemberName(fileClassName, "buildByMap")
40+
3741
private fun buildDataClass(): TypeSpec {
3842
val properties = dataProperties
3943
.map { Pair(it.name, getKotlinType(it.type, it.directiveContainer)) }
@@ -70,7 +74,7 @@ internal abstract class AbstractInputDataClassGenerator(
7074
private fun createBuilderFun(): FunSpec {
7175
val namedParameters = dataProperties
7276
.joinToString(", ") { "${it.name} = resolve${NamingHelper.uppercaseFirstLetter(it.name)}(map)" }
73-
return FunSpec.builder("buildByMap")
77+
return FunSpec.builder(buildByMapMemberName.simpleName)
7478
.addParameter("map", MAP.parameterizedBy(STRING, ANY))
7579
.returns(fileClassName)
7680
.addStatement("return %T($namedParameters)", fileClassName)

0 commit comments

Comments
 (0)