From c8900020994548ac96b10160ef11f41684d5e457 Mon Sep 17 00:00:00 2001 From: uniumuniu Date: Sun, 14 Jan 2024 22:16:04 +0100 Subject: [PATCH] Revert removing SegmentKey alias --- src/main/kotlin/com/featurevisor/sdk/DatafileReader.kt | 3 ++- src/main/kotlin/com/featurevisor/types/Types.kt | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/featurevisor/sdk/DatafileReader.kt b/src/main/kotlin/com/featurevisor/sdk/DatafileReader.kt index 7834b77..eef4c77 100644 --- a/src/main/kotlin/com/featurevisor/sdk/DatafileReader.kt +++ b/src/main/kotlin/com/featurevisor/sdk/DatafileReader.kt @@ -6,6 +6,7 @@ import com.featurevisor.types.DatafileContent import com.featurevisor.types.Feature import com.featurevisor.types.FeatureKey import com.featurevisor.types.Segment +import com.featurevisor.types.SegmentKey class DatafileReader constructor( datafileJson: DatafileContent, @@ -33,7 +34,7 @@ class DatafileReader constructor( return attributes.find { attribute -> attribute.key == attributeKey } } - fun getSegment(segmentKey: String): Segment? { + fun getSegment(segmentKey: SegmentKey): Segment? { return segments.find { segment -> segment.key == segmentKey } } diff --git a/src/main/kotlin/com/featurevisor/types/Types.kt b/src/main/kotlin/com/featurevisor/types/Types.kt index 862f296..ea1d9f8 100644 --- a/src/main/kotlin/com/featurevisor/types/Types.kt +++ b/src/main/kotlin/com/featurevisor/types/Types.kt @@ -186,7 +186,7 @@ data class SegmentAssertion( ) data class TestSegment( - val key: String, + val key: SegmentKey, val assertions: List, ) @@ -238,10 +238,12 @@ sealed class ConditionValue { data class DateTimeValue(val value: LocalDate) : ConditionValue() } +typealias SegmentKey = String + @Serializable data class Segment( val archived: Boolean? = null, - val key: String, + val key: SegmentKey, val conditions: Condition, ) @@ -259,7 +261,7 @@ data class NotGroupSegment( @Serializable(with = GroupSegmentSerializer::class) sealed class GroupSegment { - data class Plain(val segment: String) : GroupSegment() + data class Plain(val segment: SegmentKey) : GroupSegment() data class Multiple(val segments: List) : GroupSegment() data class And(val segment: AndGroupSegment) : GroupSegment() data class Or(val segment: OrGroupSegment) : GroupSegment()