diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt index c76f2682f..e9da75afb 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt @@ -6,6 +6,9 @@ import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.KModifier.OVERRIDE +import com.squareup.kotlinpoet.KModifier.PRIVATE +import com.squareup.kotlinpoet.KModifier.VARARG import com.squareup.kotlinpoet.MemberName import com.squareup.kotlinpoet.ParameterSpec import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy @@ -15,12 +18,14 @@ import com.squareup.kotlinpoet.TypeSpec import com.squareup.kotlinpoet.asClassName import com.squareup.kotlinpoet.asTypeName import com.squareup.kotlinpoet.buildCodeBlock +import com.squareup.kotlinpoet.joinToCode import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.MetadataRevision import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource import io.github.typesafegithub.workflows.actionbindinggenerator.domain.prettyPrint import io.github.typesafegithub.workflows.actionbindinggenerator.generation.Properties.CUSTOM_INPUTS import io.github.typesafegithub.workflows.actionbindinggenerator.generation.Properties.CUSTOM_VERSION +import io.github.typesafegithub.workflows.actionbindinggenerator.generation.Types.nullableAny import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Input import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.Metadata import io.github.typesafegithub.workflows.actionbindinggenerator.metadata.fetchMetadata @@ -36,6 +41,8 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.utils.toCamelCa import io.github.typesafegithub.workflows.actionbindinggenerator.utils.toKotlinPackageName import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion.V1 +import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion.V2 +import java.util.Objects public data class ActionBinding( val kotlinCode: String, @@ -47,6 +54,7 @@ public data class ActionBinding( private object Types { val mapStringString = Map::class.asTypeName().parameterizedBy(String::class.asTypeName(), String::class.asTypeName()) + val nullableAny = Any::class.asTypeName().copy(nullable = true) val nullableString = String::class.asTypeName().copy(nullable = true) val mapToList = MemberName("kotlin.collections", "toList") val listToArray = MemberName("kotlin.collections", "toTypedArray") @@ -133,69 +141,97 @@ private fun generateActionBindingSourceCode( untypedClass: Boolean = false, replaceWith: CodeBlock? = null, ): String { + val packageName = "io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}" val fileSpec = FileSpec - .builder( - "io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}", - className, - ).addFileComment( + .builder(packageName, className) + .addFileComment( """ This file was generated using action-binding-generator. Don't change it by hand, otherwise your changes will be overwritten with the next binding code regeneration. See https://github.com/typesafegithub/github-workflows-kt for more info. """.trimIndent(), - ).addType(generateActionClass(metadata, coords, bindingVersion, inputTypings, className, untypedClass, replaceWith)) - .addSuppressAnnotation(metadata) - .indent(" ") + ).addType( + generateActionClass( + metadata, + coords, + bindingVersion, + inputTypings, + packageName, + className, + untypedClass, + replaceWith, + ), + ).addSuppressAnnotation( + bindingVersion = bindingVersion, + classIsDeprecated = replaceWith != null, + metadata = metadata, + ).indent(" ") .build() return buildString { fileSpec.writeTo(this) } } -private fun FileSpec.Builder.addSuppressAnnotation(metadata: Metadata) = - apply { - val isDeprecatedInputUsed = metadata.inputs.values.any { it.deprecationMessage.isNullOrBlank().not() } - - addAnnotation( - AnnotationSpec - .builder(Suppress::class.asClassName()) - .addMember(CodeBlock.of("%S", "DataClassPrivateConstructor")) - .addMember(CodeBlock.of("%S", "UNUSED_PARAMETER")) - .apply { - if (isDeprecatedInputUsed) { - addMember(CodeBlock.of("%S", "DEPRECATION")) - } - }.build(), - ) +private fun FileSpec.Builder.addSuppressAnnotation( + bindingVersion: BindingVersion, + classIsDeprecated: Boolean, + metadata: Metadata, +): FileSpec.Builder { + val suppress = AnnotationSpec.builder(Suppress::class.asClassName()) + if (bindingVersion <= V1) { + suppress.addMember(CodeBlock.of("%S", "DataClassPrivateConstructor")) + } + suppress.addMember(CodeBlock.of("%S", "UNUSED_PARAMETER")) + val isDeprecatedInputUsed = metadata.inputs.values.any { it.deprecationMessage.isNullOrBlank().not() } + if (bindingVersion.isDeprecated || ((bindingVersion >= V2) && classIsDeprecated) || isDeprecatedInputUsed) { + suppress.addMember(CodeBlock.of("%S", "DEPRECATION")) } + addAnnotation(suppress.build()) + return this +} private fun generateActionClass( metadata: Metadata, coords: ActionCoords, bindingVersion: BindingVersion, inputTypings: Map, + packageName: String, className: String, untypedClass: Boolean, replaceWith: CodeBlock?, -): TypeSpec = - TypeSpec +): TypeSpec { + val commonConstructorParameters = + metadata.buildCommonConstructorParameters(inputTypings, coords, className, untypedClass) + return TypeSpec .classBuilder(className) - .addModifiers(KModifier.DATA) + .addDataModifier(bindingVersion) .addKdocIfNotEmpty(actionKdoc(metadata, coords, untypedClass)) .deprecateBindingVersion(bindingVersion) .replaceWith(bindingVersion, replaceWith) - .addClassConstructorAnnotation() + .addClassConstructorAnnotation(bindingVersion) .inheritsFromRegularAction(coords, metadata, className) - .primaryConstructor(metadata.primaryConstructor(inputTypings, coords, className, untypedClass)) + .primaryConstructor(buildPrimaryConstructor(bindingVersion, commonConstructorParameters)) .properties(metadata, coords, inputTypings, className, untypedClass) .addInitializerBlock(metadata, bindingVersion, coords, inputTypings, untypedClass) - .addFunction(metadata.secondaryConstructor(inputTypings, coords, className, untypedClass)) + .addSecondaryConstructor(bindingVersion, metadata, inputTypings, commonConstructorParameters, untypedClass) .addFunction(metadata.buildToYamlArgumentsFunction(inputTypings, untypedClass)) + .addEqualsFunction(bindingVersion, className, commonConstructorParameters) + .addHashCodeFunction(bindingVersion, commonConstructorParameters) + .addToStringFunction(bindingVersion, className, commonConstructorParameters) + .addCopyFunction(bindingVersion, packageName, className, commonConstructorParameters) .addCustomTypes(inputTypings, coords, className) .addOutputClassIfNecessary(metadata) .addBuildOutputObjectFunctionIfNecessary(metadata) .build() +} + +private fun TypeSpec.Builder.addDataModifier(bindingVersion: BindingVersion): TypeSpec.Builder { + if (bindingVersion <= V1) { + addModifiers(KModifier.DATA) + } + return this +} private fun TypeSpec.Builder.addCustomTypes( typings: Map, @@ -309,7 +345,7 @@ private fun TypeSpec.Builder.addBuildOutputObjectFunctionIfNecessary(metadata: M FunSpec .builder("buildOutputObject") .returns(if (metadata.outputs.isEmpty()) OutputsBase else ClassName("", "Outputs")) - .addModifiers(KModifier.OVERRIDE) + .addModifiers(OVERRIDE) .addParameter("stepId", String::class) .addCode(CodeBlock.of("return Outputs(stepId)")) .build(), @@ -335,7 +371,7 @@ private fun Metadata.buildToYamlArgumentsFunction( untypedClass: Boolean, ) = FunSpec .builder("toYamlArguments") - .addModifiers(KModifier.OVERRIDE) + .addModifiers(OVERRIDE) .returns(LinkedHashMap::class.parameterizedBy(String::class, String::class)) .addAnnotation( AnnotationSpec @@ -405,12 +441,14 @@ private fun TypeSpec.Builder.replaceWith( return this } -private fun TypeSpec.Builder.addClassConstructorAnnotation(): TypeSpec.Builder { - addAnnotation( - AnnotationSpec - .builder(ExposedCopyVisibility::class.asClassName()) - .build(), - ) +private fun TypeSpec.Builder.addClassConstructorAnnotation(bindingVersion: BindingVersion): TypeSpec.Builder { + if (bindingVersion <= V1) { + addAnnotation( + AnnotationSpec + .builder(ExposedCopyVisibility::class.asClassName()) + .build(), + ) + } return this } @@ -439,22 +477,42 @@ private fun TypeSpec.Builder.inheritsFromRegularAction( .addSuperclassConstructorParameter("_customVersion ?: %S", coords.version) } -private fun Metadata.primaryConstructor( +private fun buildPrimaryConstructor( + bindingVersion: BindingVersion, + commonConstructorParameters: Iterable, +): FunSpec { + val constructor = FunSpec.constructorBuilder() + if (bindingVersion <= V1) { + constructor.addModifiers(PRIVATE) + } + if (bindingVersion >= V2) { + constructor + .addParameter( + ParameterSpec + .builder("pleaseUseNamedArguments", Unit::class) + .addModifiers(VARARG) + .build(), + ) + } + return constructor.addParameters(commonConstructorParameters).build() +} + +private fun TypeSpec.Builder.addSecondaryConstructor( + bindingVersion: BindingVersion, + metadata: Metadata, inputTypings: Map, - coords: ActionCoords, - className: String, + commonConstructorParameters: Iterable, untypedClass: Boolean, -): FunSpec = - FunSpec - .constructorBuilder() - .addModifiers(KModifier.PRIVATE) - .addParameters(buildCommonConstructorParameters(inputTypings, coords, className, untypedClass)) - .build() +): TypeSpec.Builder { + if (bindingVersion <= V1) { + addFunction(metadata.buildSecondaryConstructor(inputTypings, commonConstructorParameters, untypedClass)) + } + return this +} -private fun Metadata.secondaryConstructor( +private fun Metadata.buildSecondaryConstructor( inputTypings: Map, - coords: ActionCoords, - className: String, + commonConstructorParameters: Iterable, untypedClass: Boolean, ): FunSpec = FunSpec @@ -462,9 +520,9 @@ private fun Metadata.secondaryConstructor( .addParameter( ParameterSpec .builder("pleaseUseNamedArguments", Unit::class) - .addModifiers(KModifier.VARARG) + .addModifiers(VARARG) .build(), - ).addParameters(buildCommonConstructorParameters(inputTypings, coords, className, untypedClass)) + ).addParameters(commonConstructorParameters) .callThisConstructor( inputs .keys @@ -541,6 +599,197 @@ private fun Metadata.buildCommonConstructorParameters( ).build(), ) +private fun TypeSpec.Builder.addEqualsFunction( + bindingVersion: BindingVersion, + className: String, + commonConstructorParameters: Iterable, +): TypeSpec.Builder { + if (bindingVersion >= V2) { + addFunction(buildEqualsFunction(className, commonConstructorParameters)) + } + return this +} + +private fun buildEqualsFunction( + className: String, + commonConstructorParameters: Iterable, +) = FunSpec + .builder("equals") + .addModifiers(OVERRIDE) + .addParameter(ParameterSpec.builder("other", nullableAny).build()) + .returns(Boolean::class) + .addCode( + buildCodeBlock { + addStatement("if (this === other) return true") + addStatement("if (javaClass != other?.javaClass) return false") + addStatement("other as %N", className) + + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return true") + 1 -> addStatement("return %1N == other.%1N", propertyNames.first()) + else -> { + add("return %1N == other.%1N &&\n", propertyNames.first()) + add( + propertyNames.drop(1).joinToCode( + separator = " &&\n", + ) { + buildCodeBlock { + indent() + add("%1N == other.%1N", it) + unindent() + } + }, + ) + } + } + }, + ).build() + +private fun TypeSpec.Builder.addHashCodeFunction( + bindingVersion: BindingVersion, + commonConstructorParameters: Iterable, +) = apply { + if (bindingVersion >= V2) { + addFunction(buildHashCodeFunction(commonConstructorParameters)) + } +} + +private fun buildHashCodeFunction(commonConstructorParameters: Iterable) = + FunSpec + .builder("hashCode") + .addModifiers(OVERRIDE) + .returns(Int::class) + .addCode( + buildCodeBlock { + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return 0") + 1 -> addStatement("return %T.hash(%N)", Objects::class, propertyNames.first()) + else -> { + add("return %T.hash(\n", Objects::class) + add( + propertyNames.joinToCode( + separator = ",\n", + suffix = ",\n)", + ) { + buildCodeBlock { + indent() + add("%N", it) + unindent() + } + }, + ) + } + } + }, + ).build() + +private fun TypeSpec.Builder.addToStringFunction( + bindingVersion: BindingVersion, + className: String, + commonConstructorParameters: Iterable, +): TypeSpec.Builder { + if (bindingVersion >= V2) { + addFunction(buildToStringFunction(className, commonConstructorParameters)) + } + return this +} + +private fun buildToStringFunction( + className: String, + commonConstructorParameters: Iterable, +) = FunSpec + .builder("toString") + .addModifiers(OVERRIDE) + .returns(String::class) + .addCode( + buildCodeBlock { + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return %S", "$className()") + + 1 -> + addStatement( + "return %P", + CodeBlock.of("%1L(%2L=$%2N)", className, propertyNames.first()), + ) + + else -> { + beginControlFlow("return buildString") + addStatement("append(%S)", "$className(") + propertyNames.dropLast(1).forEach { + addStatement( + "append(%P)", + CodeBlock.of("%1L=$%1N", it), + ) + addStatement("append(%S)", ", ") + } + addStatement( + "append(%P)", + CodeBlock.of("%1L=$%1N", propertyNames.last()), + ) + addStatement("append(%S)", ")") + endControlFlow() + } + } + }, + ).build() + +private fun TypeSpec.Builder.addCopyFunction( + bindingVersion: BindingVersion, + packageName: String, + className: String, + commonConstructorParameters: Iterable, +): TypeSpec.Builder { + if (bindingVersion >= V2) { + addFunction(buildCopyFunction(packageName, className, commonConstructorParameters)) + } + return this +} + +private fun buildCopyFunction( + packageName: String, + className: String, + commonConstructorParameters: Iterable, +) = FunSpec + .builder("copy") + .returns(ClassName(packageName, className)) + .addParameter( + ParameterSpec + .builder("pleaseUseNamedArguments", Unit::class) + .addModifiers(VARARG) + .build(), + ).addParameters( + commonConstructorParameters + .map { it.toBuilder().defaultValue("this.%N", it.name).build() }, + ).addCode( + buildCodeBlock { + val propertyNames = commonConstructorParameters.map { it.name } + when (propertyNames.size) { + 0 -> addStatement("return %N()", className) + + 1 -> addStatement("return %1N(%2N = %2N)", className, propertyNames.first()) + + else -> { + add("return %1N(\n", className) + add( + propertyNames.joinToCode( + separator = "", + suffix = ")", + ) { + buildCodeBlock { + indent() + add("%1N = %1N,\n", it) + unindent() + } + }, + ) + } + } + }, + ).build() + private fun ParameterSpec.Builder.defaultValueIfNullable( input: Input, untypedClass: Boolean, diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt index b8bad401d..ba332b8d7 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt @@ -1,18 +1,16 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any import kotlin.Boolean -import kotlin.ExposedCopyVisibility import kotlin.Float import kotlin.Int import kotlin.String @@ -59,8 +57,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithAllTypesOfInputsBindingV2 private constructor( +public class ActionWithAllTypesOfInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Short description */ @@ -247,44 +245,6 @@ public data class ActionWithAllTypesOfInputsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - bazGoo: Boolean? = null, - bazGoo_Untyped: String? = null, - binKin: Boolean? = null, - binKin_Untyped: String? = null, - intPint: Int? = null, - intPint_Untyped: String? = null, - floPint: Float? = null, - floPint_Untyped: String? = null, - finBin: ActionWithAllTypesOfInputsBindingV2.Bin? = null, - finBin_Untyped: String? = null, - gooZen: ActionWithAllTypesOfInputsBindingV2.Zen? = null, - gooZen_Untyped: String? = null, - bahEnum: ActionWithAllTypesOfInputsBindingV2.BahEnum? = null, - bahEnum_Untyped: String? = null, - listStrings: List? = null, - listStrings_Untyped: String? = null, - listInts: List? = null, - listInts_Untyped: String? = null, - listEnums: List? = null, - listEnums_Untyped: String? = null, - listIntSpecial: List? = null, - listIntSpecial_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = - bazGoo_Untyped, binKin = binKin, binKin_Untyped = binKin_Untyped, intPint = intPint, - intPint_Untyped = intPint_Untyped, floPint = floPint, floPint_Untyped = floPint_Untyped, - finBin = finBin, finBin_Untyped = finBin_Untyped, gooZen = gooZen, gooZen_Untyped = - gooZen_Untyped, bahEnum = bahEnum, bahEnum_Untyped = bahEnum_Untyped, listStrings = - listStrings, listStrings_Untyped = listStrings_Untyped, listInts = listInts, - listInts_Untyped = listInts_Untyped, listEnums = listEnums, listEnums_Untyped = - listEnums_Untyped, listIntSpecial = listIntSpecial, listIntSpecial_Untyped = - listIntSpecial_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -317,6 +277,210 @@ public data class ActionWithAllTypesOfInputsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithAllTypesOfInputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + bazGoo == other.bazGoo && + bazGoo_Untyped == other.bazGoo_Untyped && + binKin == other.binKin && + binKin_Untyped == other.binKin_Untyped && + intPint == other.intPint && + intPint_Untyped == other.intPint_Untyped && + floPint == other.floPint && + floPint_Untyped == other.floPint_Untyped && + finBin == other.finBin && + finBin_Untyped == other.finBin_Untyped && + gooZen == other.gooZen && + gooZen_Untyped == other.gooZen_Untyped && + bahEnum == other.bahEnum && + bahEnum_Untyped == other.bahEnum_Untyped && + listStrings == other.listStrings && + listStrings_Untyped == other.listStrings_Untyped && + listInts == other.listInts && + listInts_Untyped == other.listInts_Untyped && + listEnums == other.listEnums && + listEnums_Untyped == other.listEnums_Untyped && + listIntSpecial == other.listIntSpecial && + listIntSpecial_Untyped == other.listIntSpecial_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + bazGoo, + bazGoo_Untyped, + binKin, + binKin_Untyped, + intPint, + intPint_Untyped, + floPint, + floPint_Untyped, + finBin, + finBin_Untyped, + gooZen, + gooZen_Untyped, + bahEnum, + bahEnum_Untyped, + listStrings, + listStrings_Untyped, + listInts, + listInts_Untyped, + listEnums, + listEnums_Untyped, + listIntSpecial, + listIntSpecial_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithAllTypesOfInputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo=$bazGoo""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""binKin=$binKin""") + append(", ") + append("""binKin_Untyped=$binKin_Untyped""") + append(", ") + append("""intPint=$intPint""") + append(", ") + append("""intPint_Untyped=$intPint_Untyped""") + append(", ") + append("""floPint=$floPint""") + append(", ") + append("""floPint_Untyped=$floPint_Untyped""") + append(", ") + append("""finBin=$finBin""") + append(", ") + append("""finBin_Untyped=$finBin_Untyped""") + append(", ") + append("""gooZen=$gooZen""") + append(", ") + append("""gooZen_Untyped=$gooZen_Untyped""") + append(", ") + append("""bahEnum=$bahEnum""") + append(", ") + append("""bahEnum_Untyped=$bahEnum_Untyped""") + append(", ") + append("""listStrings=$listStrings""") + append(", ") + append("""listStrings_Untyped=$listStrings_Untyped""") + append(", ") + append("""listInts=$listInts""") + append(", ") + append("""listInts_Untyped=$listInts_Untyped""") + append(", ") + append("""listEnums=$listEnums""") + append(", ") + append("""listEnums_Untyped=$listEnums_Untyped""") + append(", ") + append("""listIntSpecial=$listIntSpecial""") + append(", ") + append("""listIntSpecial_Untyped=$listIntSpecial_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Short description + * @param fooBar_Untyped <required> Short description + * @param bazGoo <required> First boolean input! + * @param bazGoo_Untyped <required> First boolean input! + * @param binKin Boolean and nullable + * @param binKin_Untyped Boolean and nullable + * @param intPint <required> Integer + * @param intPint_Untyped <required> Integer + * @param floPint <required> Float + * @param floPint_Untyped <required> Float + * @param finBin <required> Enumeration + * @param finBin_Untyped <required> Enumeration + * @param gooZen <required> Integer with special value + * @param gooZen_Untyped <required> Integer with special value + * @param bahEnum <required> Enum with custom naming + * @param bahEnum_Untyped <required> Enum with custom naming + * @param listStrings List of strings + * @param listStrings_Untyped List of strings + * @param listInts List of integers + * @param listInts_Untyped List of integers + * @param listEnums List of enums + * @param listEnums_Untyped List of enums + * @param listIntSpecial List of integer with special values + * @param listIntSpecial_Untyped List of integer with special values + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + bazGoo: Boolean? = this.bazGoo, + bazGoo_Untyped: String? = this.bazGoo_Untyped, + binKin: Boolean? = this.binKin, + binKin_Untyped: String? = this.binKin_Untyped, + intPint: Int? = this.intPint, + intPint_Untyped: String? = this.intPint_Untyped, + floPint: Float? = this.floPint, + floPint_Untyped: String? = this.floPint_Untyped, + finBin: ActionWithAllTypesOfInputsBindingV2.Bin? = this.finBin, + finBin_Untyped: String? = this.finBin_Untyped, + gooZen: ActionWithAllTypesOfInputsBindingV2.Zen? = this.gooZen, + gooZen_Untyped: String? = this.gooZen_Untyped, + bahEnum: ActionWithAllTypesOfInputsBindingV2.BahEnum? = this.bahEnum, + bahEnum_Untyped: String? = this.bahEnum_Untyped, + listStrings: List? = this.listStrings, + listStrings_Untyped: String? = this.listStrings_Untyped, + listInts: List? = this.listInts, + listInts_Untyped: String? = this.listInts_Untyped, + listEnums: List? = this.listEnums, + listEnums_Untyped: String? = this.listEnums_Untyped, + listIntSpecial: List? = this.listIntSpecial, + listIntSpecial_Untyped: String? = this.listIntSpecial_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithAllTypesOfInputsBindingV2 = ActionWithAllTypesOfInputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + bazGoo = bazGoo, + bazGoo_Untyped = bazGoo_Untyped, + binKin = binKin, + binKin_Untyped = binKin_Untyped, + intPint = intPint, + intPint_Untyped = intPint_Untyped, + floPint = floPint, + floPint_Untyped = floPint_Untyped, + finBin = finBin, + finBin_Untyped = finBin_Untyped, + gooZen = gooZen, + gooZen_Untyped = gooZen_Untyped, + bahEnum = bahEnum, + bahEnum_Untyped = bahEnum_Untyped, + listStrings = listStrings, + listStrings_Untyped = listStrings_Untyped, + listInts = listInts, + listInts_Untyped = listInts_Untyped, + listEnums = listEnums, + listEnums_Untyped = listEnums_Untyped, + listIntSpecial = listIntSpecial, + listIntSpecial_Untyped = listIntSpecial_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) public sealed class Bin( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt index 6a2474e6d..bc63eeb7f 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2_Untyped.kt @@ -2,8 +2,8 @@ // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. @file:Suppress( - "DataClassPrivateConstructor", "UNUSED_PARAMETER", + "DEPRECATION", ) package io.github.typesafegithub.workflows.actions.johnsmith @@ -11,8 +11,11 @@ package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Deprecated -import kotlin.ExposedCopyVisibility +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -68,8 +71,8 @@ import kotlin.collections.toTypedArray "Use the typed class instead", ReplaceWith("ActionWithAllTypesOfInputsBindingV2"), ) -@ExposedCopyVisibility -public data class ActionWithAllTypesOfInputsBindingV2_Untyped private constructor( +public class ActionWithAllTypesOfInputsBindingV2_Untyped( + vararg pleaseUseNamedArguments: Unit, /** * Short description */ @@ -140,29 +143,6 @@ public data class ActionWithAllTypesOfInputsBindingV2_Untyped private constructo } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar_Untyped: String, - bazGoo_Untyped: String, - binKin_Untyped: String? = null, - intPint_Untyped: String, - floPint_Untyped: String, - finBin_Untyped: String, - gooZen_Untyped: String, - bahEnum_Untyped: String, - listStrings_Untyped: String? = null, - listInts_Untyped: String? = null, - listEnums_Untyped: String? = null, - listIntSpecial_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar_Untyped = fooBar_Untyped, bazGoo_Untyped = bazGoo_Untyped, binKin_Untyped = - binKin_Untyped, intPint_Untyped = intPint_Untyped, floPint_Untyped = floPint_Untyped, - finBin_Untyped = finBin_Untyped, gooZen_Untyped = gooZen_Untyped, bahEnum_Untyped = - bahEnum_Untyped, listStrings_Untyped = listStrings_Untyped, listInts_Untyped = - listInts_Untyped, listEnums_Untyped = listEnums_Untyped, listIntSpecial_Untyped = - listIntSpecial_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -182,6 +162,126 @@ public data class ActionWithAllTypesOfInputsBindingV2_Untyped private constructo ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithAllTypesOfInputsBindingV2_Untyped + return fooBar_Untyped == other.fooBar_Untyped && + bazGoo_Untyped == other.bazGoo_Untyped && + binKin_Untyped == other.binKin_Untyped && + intPint_Untyped == other.intPint_Untyped && + floPint_Untyped == other.floPint_Untyped && + finBin_Untyped == other.finBin_Untyped && + gooZen_Untyped == other.gooZen_Untyped && + bahEnum_Untyped == other.bahEnum_Untyped && + listStrings_Untyped == other.listStrings_Untyped && + listInts_Untyped == other.listInts_Untyped && + listEnums_Untyped == other.listEnums_Untyped && + listIntSpecial_Untyped == other.listIntSpecial_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar_Untyped, + bazGoo_Untyped, + binKin_Untyped, + intPint_Untyped, + floPint_Untyped, + finBin_Untyped, + gooZen_Untyped, + bahEnum_Untyped, + listStrings_Untyped, + listInts_Untyped, + listEnums_Untyped, + listIntSpecial_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithAllTypesOfInputsBindingV2_Untyped(") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""binKin_Untyped=$binKin_Untyped""") + append(", ") + append("""intPint_Untyped=$intPint_Untyped""") + append(", ") + append("""floPint_Untyped=$floPint_Untyped""") + append(", ") + append("""finBin_Untyped=$finBin_Untyped""") + append(", ") + append("""gooZen_Untyped=$gooZen_Untyped""") + append(", ") + append("""bahEnum_Untyped=$bahEnum_Untyped""") + append(", ") + append("""listStrings_Untyped=$listStrings_Untyped""") + append(", ") + append("""listInts_Untyped=$listInts_Untyped""") + append(", ") + append("""listEnums_Untyped=$listEnums_Untyped""") + append(", ") + append("""listIntSpecial_Untyped=$listIntSpecial_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar_Untyped Short description + * @param bazGoo_Untyped First boolean input! + * @param binKin_Untyped Boolean and nullable + * @param intPint_Untyped Integer + * @param floPint_Untyped Float + * @param finBin_Untyped Enumeration + * @param gooZen_Untyped Integer with special value + * @param bahEnum_Untyped Enum with custom naming + * @param listStrings_Untyped List of strings + * @param listInts_Untyped List of integers + * @param listEnums_Untyped List of enums + * @param listIntSpecial_Untyped List of integer with special values + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar_Untyped: String = this.fooBar_Untyped, + bazGoo_Untyped: String = this.bazGoo_Untyped, + binKin_Untyped: String? = this.binKin_Untyped, + intPint_Untyped: String = this.intPint_Untyped, + floPint_Untyped: String = this.floPint_Untyped, + finBin_Untyped: String = this.finBin_Untyped, + gooZen_Untyped: String = this.gooZen_Untyped, + bahEnum_Untyped: String = this.bahEnum_Untyped, + listStrings_Untyped: String? = this.listStrings_Untyped, + listInts_Untyped: String? = this.listInts_Untyped, + listEnums_Untyped: String? = this.listEnums_Untyped, + listIntSpecial_Untyped: String? = this.listIntSpecial_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithAllTypesOfInputsBindingV2_Untyped = ActionWithAllTypesOfInputsBindingV2_Untyped( + fooBar_Untyped = fooBar_Untyped, + bazGoo_Untyped = bazGoo_Untyped, + binKin_Untyped = binKin_Untyped, + intPint_Untyped = intPint_Untyped, + floPint_Untyped = floPint_Untyped, + finBin_Untyped = finBin_Untyped, + gooZen_Untyped = gooZen_Untyped, + bahEnum_Untyped = bahEnum_Untyped, + listStrings_Untyped = listStrings_Untyped, + listInts_Untyped = listInts_Untyped, + listEnums_Untyped = listEnums_Untyped, + listIntSpecial_Untyped = listIntSpecial_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) public class Outputs( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt index 508421d59..bd02aaf41 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt @@ -226,7 +226,6 @@ class ActionWithAllTypesOfInputsTest : DescribeSpec({ V2 -> { // when action as ActionWithAllTypesOfInputsBindingV2 - @Suppress("DATA_CLASS_INVISIBLE_COPY_USAGE_WARNING") val actionWithOneChange = action.copy(fooBar = "another") // then diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt index 257480ae7..0bd420ee2 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClashBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -34,8 +34,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithDeprecatedInputAndNameClashBindingV2 private constructor( +public class ActionWithDeprecatedInputAndNameClashBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Foo bar - new */ @@ -72,15 +72,6 @@ public data class ActionWithDeprecatedInputAndNameClashBindingV2 private constru } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, _customInputs = _customInputs, - _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -90,5 +81,56 @@ public data class ActionWithDeprecatedInputAndNameClashBindingV2 private constru ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithDeprecatedInputAndNameClashBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithDeprecatedInputAndNameClashBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Foo bar - new + * @param fooBar_Untyped <required> Foo bar - new + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithDeprecatedInputAndNameClashBindingV2 = + ActionWithDeprecatedInputAndNameClashBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt index e6ce31137..5d8bc5261 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -35,8 +35,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithFancyCharsInDocsBindingV2 private constructor( +public class ActionWithFancyCharsInDocsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * This is a /* test */ */ @@ -82,18 +82,6 @@ public data class ActionWithFancyCharsInDocsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - nestedKotlinComments: String? = null, - nestedKotlinComments_Untyped: String? = null, - percent: String? = null, - percent_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(nestedKotlinComments = nestedKotlinComments, nestedKotlinComments_Untyped = - nestedKotlinComments_Untyped, percent = percent, percent_Untyped = percent_Untyped, - _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -105,5 +93,69 @@ public data class ActionWithFancyCharsInDocsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithFancyCharsInDocsBindingV2 + return nestedKotlinComments == other.nestedKotlinComments && + nestedKotlinComments_Untyped == other.nestedKotlinComments_Untyped && + percent == other.percent && + percent_Untyped == other.percent_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + nestedKotlinComments, + nestedKotlinComments_Untyped, + percent, + percent_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithFancyCharsInDocsBindingV2(") + append("""nestedKotlinComments=$nestedKotlinComments""") + append(", ") + append("""nestedKotlinComments_Untyped=$nestedKotlinComments_Untyped""") + append(", ") + append("""percent=$percent""") + append(", ") + append("""percent_Untyped=$percent_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param nestedKotlinComments This is a /* test */ + * @param nestedKotlinComments_Untyped This is a /* test */ + * @param percent For example "100%" + * @param percent_Untyped For example "100%" + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + nestedKotlinComments: String? = this.nestedKotlinComments, + nestedKotlinComments_Untyped: String? = this.nestedKotlinComments_Untyped, + percent: String? = this.percent, + percent_Untyped: String? = this.percent_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithFancyCharsInDocsBindingV2 = ActionWithFancyCharsInDocsBindingV2( + nestedKotlinComments = nestedKotlinComments, + nestedKotlinComments_Untyped = nestedKotlinComments_Untyped, + percent = percent, + percent_Untyped = percent_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt index 094218f57..ac941fe82 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingTypeBindingV2.kt @@ -1,17 +1,16 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Int import kotlin.String import kotlin.Suppress @@ -36,8 +35,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithInputsSharingTypeBindingV2 private constructor( +public class ActionWithInputsSharingTypeBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> */ @@ -95,20 +94,6 @@ public data class ActionWithInputsSharingTypeBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooOne: ActionWithInputsSharingTypeBindingV2.Foo? = null, - fooOne_Untyped: String? = null, - fooTwo: ActionWithInputsSharingTypeBindingV2.Foo? = null, - fooTwo_Untyped: String? = null, - fooThree: ActionWithInputsSharingTypeBindingV2.Foo? = null, - fooThree_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooOne = fooOne, fooOne_Untyped = fooOne_Untyped, fooTwo = fooTwo, fooTwo_Untyped = - fooTwo_Untyped, fooThree = fooThree, fooThree_Untyped = fooThree_Untyped, _customInputs - = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -122,6 +107,82 @@ public data class ActionWithInputsSharingTypeBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithInputsSharingTypeBindingV2 + return fooOne == other.fooOne && + fooOne_Untyped == other.fooOne_Untyped && + fooTwo == other.fooTwo && + fooTwo_Untyped == other.fooTwo_Untyped && + fooThree == other.fooThree && + fooThree_Untyped == other.fooThree_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooOne, + fooOne_Untyped, + fooTwo, + fooTwo_Untyped, + fooThree, + fooThree_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithInputsSharingTypeBindingV2(") + append("""fooOne=$fooOne""") + append(", ") + append("""fooOne_Untyped=$fooOne_Untyped""") + append(", ") + append("""fooTwo=$fooTwo""") + append(", ") + append("""fooTwo_Untyped=$fooTwo_Untyped""") + append(", ") + append("""fooThree=$fooThree""") + append(", ") + append("""fooThree_Untyped=$fooThree_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooOne <required> + * @param fooOne_Untyped <required> + * @param fooTwo <required> + * @param fooTwo_Untyped <required> + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooOne: ActionWithInputsSharingTypeBindingV2.Foo? = this.fooOne, + fooOne_Untyped: String? = this.fooOne_Untyped, + fooTwo: ActionWithInputsSharingTypeBindingV2.Foo? = this.fooTwo, + fooTwo_Untyped: String? = this.fooTwo_Untyped, + fooThree: ActionWithInputsSharingTypeBindingV2.Foo? = this.fooThree, + fooThree_Untyped: String? = this.fooThree_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithInputsSharingTypeBindingV2 = ActionWithInputsSharingTypeBindingV2( + fooOne = fooOne, + fooOne_Untyped = fooOne_Untyped, + fooTwo = fooTwo, + fooTwo_Untyped = fooTwo_Untyped, + fooThree = fooThree, + fooThree_Untyped = fooThree_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) public sealed class Foo( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt index e3811d9f1..0b3bd8660 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -29,8 +29,8 @@ import kotlin.collections.Map * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithNoInputsBindingV2 private constructor( +public class ActionWithNoInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * Type-unsafe map where you can put any inputs that are not yet supported by the binding */ @@ -53,14 +53,44 @@ public data class ActionWithNoInputsBindingV2 private constructor( } - public constructor( - vararg pleaseUseNamedArguments: Unit, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(_customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = LinkedHashMap(_customInputs) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithNoInputsBindingV2 + return _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithNoInputsBindingV2(") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithNoInputsBindingV2 = ActionWithNoInputsBindingV2( + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt index 613b934cb..a3e808fbb 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypingsBindingV2_Untyped.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -51,8 +51,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithNoTypingsBindingV2_Untyped private constructor( +public class ActionWithNoTypingsBindingV2_Untyped( + vararg pleaseUseNamedArguments: Unit, public val foo_Untyped: String, public val bar_Untyped: String? = null, /** @@ -77,15 +77,6 @@ public data class ActionWithNoTypingsBindingV2_Untyped private constructor( } - public constructor( - vararg pleaseUseNamedArguments: Unit, - foo_Untyped: String, - bar_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(foo_Untyped = foo_Untyped, bar_Untyped = bar_Untyped, _customInputs = _customInputs, - _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -95,5 +86,53 @@ public data class ActionWithNoTypingsBindingV2_Untyped private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithNoTypingsBindingV2_Untyped + return foo_Untyped == other.foo_Untyped && + bar_Untyped == other.bar_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + foo_Untyped, + bar_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithNoTypingsBindingV2_Untyped(") + append("""foo_Untyped=$foo_Untyped""") + append(", ") + append("""bar_Untyped=$bar_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + foo_Untyped: String = this.foo_Untyped, + bar_Untyped: String? = this.bar_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithNoTypingsBindingV2_Untyped = ActionWithNoTypingsBindingV2_Untyped( + foo_Untyped = foo_Untyped, + bar_Untyped = bar_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt index a22b149da..98d71b7c5 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithOutputsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -33,8 +33,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithOutputsBindingV2 private constructor( +public class ActionWithOutputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Short description */ @@ -71,15 +71,6 @@ public data class ActionWithOutputsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, _customInputs = _customInputs, - _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -89,6 +80,56 @@ public data class ActionWithOutputsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithOutputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithOutputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Short description + * @param fooBar_Untyped <required> Short description + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithOutputsBindingV2 = ActionWithOutputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId) public class Outputs( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt index 873a00b3a..ec9390585 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2.kt @@ -1,17 +1,16 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Int import kotlin.String import kotlin.Suppress @@ -34,8 +33,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithPartlyTypingsBindingV2 private constructor( +public class ActionWithPartlyTypingsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> */ @@ -74,17 +73,6 @@ public data class ActionWithPartlyTypingsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - foo: Int? = null, - foo_Untyped: String? = null, - bar_Untyped: String? = null, - baz_Untyped: String, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(foo = foo, foo_Untyped = foo_Untyped, bar_Untyped = bar_Untyped, baz_Untyped = - baz_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -96,5 +84,67 @@ public data class ActionWithPartlyTypingsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithPartlyTypingsBindingV2 + return foo == other.foo && + foo_Untyped == other.foo_Untyped && + bar_Untyped == other.bar_Untyped && + baz_Untyped == other.baz_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + foo, + foo_Untyped, + bar_Untyped, + baz_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithPartlyTypingsBindingV2(") + append("""foo=$foo""") + append(", ") + append("""foo_Untyped=$foo_Untyped""") + append(", ") + append("""bar_Untyped=$bar_Untyped""") + append(", ") + append("""baz_Untyped=$baz_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param foo <required> + * @param foo_Untyped <required> + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + foo: Int? = this.foo, + foo_Untyped: String? = this.foo_Untyped, + bar_Untyped: String? = this.bar_Untyped, + baz_Untyped: String = this.baz_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithPartlyTypingsBindingV2 = ActionWithPartlyTypingsBindingV2( + foo = foo, + foo_Untyped = foo_Untyped, + bar_Untyped = bar_Untyped, + baz_Untyped = baz_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt index 11d1e4788..22ab50979 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithPartlyTypingsBindingV2_Untyped.kt @@ -2,8 +2,8 @@ // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. @file:Suppress( - "DataClassPrivateConstructor", "UNUSED_PARAMETER", + "DEPRECATION", ) package io.github.typesafegithub.workflows.actions.johnsmith @@ -11,8 +11,11 @@ package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Deprecated -import kotlin.ExposedCopyVisibility +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -56,8 +59,8 @@ import kotlin.collections.toTypedArray "Use the typed class instead", ReplaceWith("ActionWithPartlyTypingsBindingV2"), ) -@ExposedCopyVisibility -public data class ActionWithPartlyTypingsBindingV2_Untyped private constructor( +public class ActionWithPartlyTypingsBindingV2_Untyped( + vararg pleaseUseNamedArguments: Unit, public val foo_Untyped: String, public val bar_Untyped: String? = null, public val baz_Untyped: String, @@ -83,16 +86,6 @@ public data class ActionWithPartlyTypingsBindingV2_Untyped private constructor( } - public constructor( - vararg pleaseUseNamedArguments: Unit, - foo_Untyped: String, - bar_Untyped: String? = null, - baz_Untyped: String, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(foo_Untyped = foo_Untyped, bar_Untyped = bar_Untyped, baz_Untyped = baz_Untyped, - _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -103,5 +96,59 @@ public data class ActionWithPartlyTypingsBindingV2_Untyped private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithPartlyTypingsBindingV2_Untyped + return foo_Untyped == other.foo_Untyped && + bar_Untyped == other.bar_Untyped && + baz_Untyped == other.baz_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + foo_Untyped, + bar_Untyped, + baz_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithPartlyTypingsBindingV2_Untyped(") + append("""foo_Untyped=$foo_Untyped""") + append(", ") + append("""bar_Untyped=$bar_Untyped""") + append(", ") + append("""baz_Untyped=$baz_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + foo_Untyped: String = this.foo_Untyped, + bar_Untyped: String? = this.bar_Untyped, + baz_Untyped: String = this.baz_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithPartlyTypingsBindingV2_Untyped = ActionWithPartlyTypingsBindingV2_Untyped( + foo_Untyped = foo_Untyped, + bar_Untyped = bar_Untyped, + baz_Untyped = baz_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt index 0604f47fb..f93741d1c 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithSomeOptionalInputsBindingV2.kt @@ -1,17 +1,17 @@ // This file was generated using action-binding-generator. Don't change it by hand, otherwise your // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. -@file:Suppress( - "DataClassPrivateConstructor", - "UNUSED_PARAMETER", -) +@file:Suppress("UNUSED_PARAMETER") package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap -import kotlin.ExposedCopyVisibility +import java.util.Objects +import kotlin.Any +import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -41,8 +41,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class ActionWithSomeOptionalInputsBindingV2 private constructor( +public class ActionWithSomeOptionalInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * Required is default, default is set */ @@ -127,25 +127,6 @@ public data class ActionWithSomeOptionalInputsBindingV2 private constructor( } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - bazGoo: String? = null, - bazGoo_Untyped: String? = null, - zooDar: String? = null, - zooDar_Untyped: String? = null, - cooPoo: String? = null, - cooPoo_Untyped: String? = null, - `package`: String? = null, - package_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = - bazGoo_Untyped, zooDar = zooDar, zooDar_Untyped = zooDar_Untyped, cooPoo = cooPoo, - cooPoo_Untyped = cooPoo_Untyped, `package` = `package`, package_Untyped = - package_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -163,5 +144,111 @@ public data class ActionWithSomeOptionalInputsBindingV2 private constructor( ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as ActionWithSomeOptionalInputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + bazGoo == other.bazGoo && + bazGoo_Untyped == other.bazGoo_Untyped && + zooDar == other.zooDar && + zooDar_Untyped == other.zooDar_Untyped && + cooPoo == other.cooPoo && + cooPoo_Untyped == other.cooPoo_Untyped && + `package` == other.`package` && + package_Untyped == other.package_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + bazGoo, + bazGoo_Untyped, + zooDar, + zooDar_Untyped, + cooPoo, + cooPoo_Untyped, + `package`, + package_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("ActionWithSomeOptionalInputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo=$bazGoo""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""zooDar=$zooDar""") + append(", ") + append("""zooDar_Untyped=$zooDar_Untyped""") + append(", ") + append("""cooPoo=$cooPoo""") + append(", ") + append("""cooPoo_Untyped=$cooPoo_Untyped""") + append(", ") + append("""package=$`package`""") + append(", ") + append("""package_Untyped=$package_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar Required is default, default is set + * @param fooBar_Untyped Required is default, default is set + * @param bazGoo Required is default, default is null + * @param bazGoo_Untyped Required is default, default is null + * @param zooDar Required is false, default is set + * @param zooDar_Untyped Required is false, default is set + * @param cooPoo Required is false, default is default + * @param cooPoo_Untyped Required is false, default is default + * @param package <required> Required is true, default is default + * @param package_Untyped <required> Required is true, default is default + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + bazGoo: String? = this.bazGoo, + bazGoo_Untyped: String? = this.bazGoo_Untyped, + zooDar: String? = this.zooDar, + zooDar_Untyped: String? = this.zooDar_Untyped, + cooPoo: String? = this.cooPoo, + cooPoo_Untyped: String? = this.cooPoo_Untyped, + `package`: String? = this.`package`, + package_Untyped: String? = this.package_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): ActionWithSomeOptionalInputsBindingV2 = ActionWithSomeOptionalInputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + bazGoo = bazGoo, + bazGoo_Untyped = bazGoo_Untyped, + zooDar = zooDar, + zooDar_Untyped = zooDar_Untyped, + cooPoo = cooPoo, + cooPoo_Untyped = cooPoo_Untyped, + `package` = `package`, + package_Untyped = package_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt index 9880b5bea..024060e4c 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/SimpleActionWithRequiredStringInputsBindingV2.kt @@ -2,7 +2,6 @@ // changes will be overwritten with the next binding code regeneration. // See https://github.com/typesafegithub/github-workflows-kt for more info. @file:Suppress( - "DataClassPrivateConstructor", "UNUSED_PARAMETER", "DEPRECATION", ) @@ -12,8 +11,11 @@ package io.github.typesafegithub.workflows.actions.johnsmith import io.github.typesafegithub.workflows.domain.actions.Action import io.github.typesafegithub.workflows.domain.actions.RegularAction import java.util.LinkedHashMap +import java.util.Objects +import kotlin.Any +import kotlin.Boolean import kotlin.Deprecated -import kotlin.ExposedCopyVisibility +import kotlin.Int import kotlin.String import kotlin.Suppress import kotlin.Unit @@ -41,8 +43,8 @@ import kotlin.collections.toTypedArray * @param _customVersion Allows overriding action's version, for example to use a specific minor * version, or a newer version that the binding doesn't yet know about */ -@ExposedCopyVisibility -public data class SimpleActionWithRequiredStringInputsBindingV2 private constructor( +public class SimpleActionWithRequiredStringInputsBindingV2( + vararg pleaseUseNamedArguments: Unit, /** * <required> Short description */ @@ -98,17 +100,6 @@ public data class SimpleActionWithRequiredStringInputsBindingV2 private construc } } - public constructor( - vararg pleaseUseNamedArguments: Unit, - fooBar: String? = null, - fooBar_Untyped: String? = null, - bazGoo: String? = null, - bazGoo_Untyped: String? = null, - _customInputs: Map = mapOf(), - _customVersion: String? = null, - ) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = - bazGoo_Untyped, _customInputs = _customInputs, _customVersion = _customVersion) - @Suppress("SpreadOperator") override fun toYamlArguments(): LinkedHashMap = linkedMapOf( *listOfNotNull( @@ -120,5 +111,72 @@ public data class SimpleActionWithRequiredStringInputsBindingV2 private construc ).toTypedArray() ) + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as SimpleActionWithRequiredStringInputsBindingV2 + return fooBar == other.fooBar && + fooBar_Untyped == other.fooBar_Untyped && + bazGoo == other.bazGoo && + bazGoo_Untyped == other.bazGoo_Untyped && + _customInputs == other._customInputs && + _customVersion == other._customVersion + } + + override fun hashCode(): Int = Objects.hash( + fooBar, + fooBar_Untyped, + bazGoo, + bazGoo_Untyped, + _customInputs, + _customVersion, + ) + + override fun toString(): String = buildString { + append("SimpleActionWithRequiredStringInputsBindingV2(") + append("""fooBar=$fooBar""") + append(", ") + append("""fooBar_Untyped=$fooBar_Untyped""") + append(", ") + append("""bazGoo=$bazGoo""") + append(", ") + append("""bazGoo_Untyped=$bazGoo_Untyped""") + append(", ") + append("""_customInputs=$_customInputs""") + append(", ") + append("""_customVersion=$_customVersion""") + append(")") + } + + /** + * @param fooBar <required> Short description + * @param fooBar_Untyped <required> Short description + * @param bazGoo <required> Just another input + * with multiline description + * @param bazGoo_Untyped <required> Just another input + * with multiline description + * @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported + * by the binding + * @param _customVersion Allows overriding action's version, for example to use a specific minor + * version, or a newer version that the binding doesn't yet know about + */ + public fun copy( + vararg pleaseUseNamedArguments: Unit, + fooBar: String? = this.fooBar, + fooBar_Untyped: String? = this.fooBar_Untyped, + bazGoo: String? = this.bazGoo, + bazGoo_Untyped: String? = this.bazGoo_Untyped, + _customInputs: Map = this._customInputs, + _customVersion: String? = this._customVersion, + ): SimpleActionWithRequiredStringInputsBindingV2 = + SimpleActionWithRequiredStringInputsBindingV2( + fooBar = fooBar, + fooBar_Untyped = fooBar_Untyped, + bazGoo = bazGoo, + bazGoo_Untyped = bazGoo_Untyped, + _customInputs = _customInputs, + _customVersion = _customVersion, + ) + override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId) } diff --git a/docs/user-guide/using-actions.md b/docs/user-guide/using-actions.md index d90246f29..c3a98f96b 100644 --- a/docs/user-guide/using-actions.md +++ b/docs/user-guide/using-actions.md @@ -119,7 +119,14 @@ anyway as defined above. `https://bindings.krzeminski.it/v2` -: TBD +: - Binding classes are no `data` classes anymore. + - The `equals` method will work like before. + - The `hashCode` method will work like before. + - The `toString` method will work like before. + - Destructuring assignments are not possible anymore as this will likely break silently or during + compilation when action owners add new inputs in between existing ones. + - The `clone` method will work like before, just that now usage of named arguments is enforced + to ensure source compatibility when action owners add new inputs in between existing ones. `https://bindings.krzeminski.it` / `https://bindings.krzeminski.it/v1`