From a0b5b88721e36f25441372739874ebae36151728 Mon Sep 17 00:00:00 2001 From: Heiko Guckes Date: Mon, 7 Apr 2025 11:00:50 +0200 Subject: [PATCH] add copy method to InsightAttribute --- .../kotlininsightclient/api/model/Model.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt b/kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt index 4d16ed5..f2e7264 100644 --- a/kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt +++ b/kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt @@ -435,6 +435,32 @@ sealed class InsightAttribute( } +fun InsightAttribute.copy( + attributeId: InsightAttributeId = this.attributeId, + schema: ObjectTypeSchemaAttribute? = this.schema, +): InsightAttribute = when (this) { + is InsightAttribute.Text -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Integer -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Bool -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.DoubleNumber -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Date -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Time -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.DateTime -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Email -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Textarea -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Ipaddress -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Url -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Select -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Reference -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.User -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Confluence -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Group -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Version -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Project -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Status -> copy(attributeId = attributeId, schema = schema) + is InsightAttribute.Unknown -> copy(attributeId = attributeId, schema = schema) +} + fun InsightAttribute.isValueAttribute() = this.type.isValueAttribute() fun ObjectTypeSchemaAttribute.isValueAttribute() = this.type.isValueAttribute()