-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Conditions and add unit tests
- Loading branch information
Showing
8 changed files
with
542 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
15 changes: 12 additions & 3 deletions
15
.../com/featurevisor/types/AttributeValue.kt → ...otlin/com/featurevisor/types/Attribute.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
package com.featurevisor.types | ||
|
||
import java.time.LocalDate | ||
|
||
typealias AttributeKey = String | ||
|
||
data class Attribute( | ||
val key: AttributeKey, | ||
val type: String, | ||
val archived: Boolean?, | ||
val capture: Boolean?, | ||
) | ||
|
||
sealed class AttributeValue { | ||
data class StringValue(val value: String) : AttributeValue() | ||
data class IntValue(val value: Int) : AttributeValue() | ||
data class DoubleValue(val value: Double) : AttributeValue() | ||
data class BooleanValue(val value: Boolean) : AttributeValue() | ||
data class ArrayValue(val values: List<String>) : AttributeValue() | ||
|
||
// @TODO: implement Date | ||
data class DateValue(val value: LocalDate) : AttributeValue() | ||
object NullValue : AttributeValue() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.featurevisor.types | ||
|
||
import java.time.LocalDate | ||
|
||
sealed class Condition { | ||
data class Plain( | ||
val attributeKey: AttributeKey, | ||
val operator: Operator, | ||
val value: ConditionValue, | ||
) : Condition() | ||
|
||
data class And(val and: List<Condition>) : Condition() | ||
data class Or(val or: List<Condition>) : Condition() | ||
data class Not(val not: List<Condition>) : Condition() | ||
} | ||
|
||
sealed class ConditionValue { | ||
data class StringValue(val value: String) : ConditionValue() | ||
data class IntValue(val value: Int) : ConditionValue() | ||
data class DoubleValue(val value: Double) : ConditionValue() | ||
data class BooleanValue(val value: Boolean) : ConditionValue() | ||
data class ArrayValue(val values: List<String>) : ConditionValue() | ||
data class DateTimeValue(val value: LocalDate) : ConditionValue() | ||
object NullValue : ConditionValue() | ||
} |
Oops, something went wrong.