Skip to content

Commit 58cce6e

Browse files
authored
add copy method to InsightAttribute (#31)
1 parent bd3f892 commit 58cce6e

File tree

1 file changed

+26
-0
lines changed
  • kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model

1 file changed

+26
-0
lines changed

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/model/Model.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,32 @@ sealed class InsightAttribute(
435435

436436
}
437437

438+
fun InsightAttribute.copy(
439+
attributeId: InsightAttributeId = this.attributeId,
440+
schema: ObjectTypeSchemaAttribute? = this.schema,
441+
): InsightAttribute = when (this) {
442+
is InsightAttribute.Text -> copy(attributeId = attributeId, schema = schema)
443+
is InsightAttribute.Integer -> copy(attributeId = attributeId, schema = schema)
444+
is InsightAttribute.Bool -> copy(attributeId = attributeId, schema = schema)
445+
is InsightAttribute.DoubleNumber -> copy(attributeId = attributeId, schema = schema)
446+
is InsightAttribute.Date -> copy(attributeId = attributeId, schema = schema)
447+
is InsightAttribute.Time -> copy(attributeId = attributeId, schema = schema)
448+
is InsightAttribute.DateTime -> copy(attributeId = attributeId, schema = schema)
449+
is InsightAttribute.Email -> copy(attributeId = attributeId, schema = schema)
450+
is InsightAttribute.Textarea -> copy(attributeId = attributeId, schema = schema)
451+
is InsightAttribute.Ipaddress -> copy(attributeId = attributeId, schema = schema)
452+
is InsightAttribute.Url -> copy(attributeId = attributeId, schema = schema)
453+
is InsightAttribute.Select -> copy(attributeId = attributeId, schema = schema)
454+
is InsightAttribute.Reference -> copy(attributeId = attributeId, schema = schema)
455+
is InsightAttribute.User -> copy(attributeId = attributeId, schema = schema)
456+
is InsightAttribute.Confluence -> copy(attributeId = attributeId, schema = schema)
457+
is InsightAttribute.Group -> copy(attributeId = attributeId, schema = schema)
458+
is InsightAttribute.Version -> copy(attributeId = attributeId, schema = schema)
459+
is InsightAttribute.Project -> copy(attributeId = attributeId, schema = schema)
460+
is InsightAttribute.Status -> copy(attributeId = attributeId, schema = schema)
461+
is InsightAttribute.Unknown -> copy(attributeId = attributeId, schema = schema)
462+
}
463+
438464
fun InsightAttribute.isValueAttribute() = this.type.isValueAttribute()
439465
fun ObjectTypeSchemaAttribute.isValueAttribute() = this.type.isValueAttribute()
440466

0 commit comments

Comments
 (0)