-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- **Replace MemoryFlagState type with existing FlagValue** - **Extract FlagValue and FlagValueType files** - **Add Structure MemoryProvider implementation**
- Loading branch information
1 parent
a5cd63b
commit 6c5042f
Showing
6 changed files
with
172 additions
and
99 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
50 changes: 50 additions & 0 deletions
50
openfeature/sdk/src/main/scala/io/cardell/openfeature/FlagValue.scala
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,50 @@ | ||
/* | ||
* Copyright 2023 Alex Cardell | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.cardell.openfeature | ||
|
||
import io.cardell.openfeature.FlagValue.BooleanValue | ||
import io.cardell.openfeature.FlagValue.DoubleValue | ||
import io.cardell.openfeature.FlagValue.IntValue | ||
import io.cardell.openfeature.FlagValue.StringValue | ||
import io.cardell.openfeature.FlagValue.StructureValue | ||
|
||
sealed trait FlagValue { | ||
|
||
def valueType: FlagValueType = | ||
this match { | ||
case _: BooleanValue => FlagValueType.BooleanValueType | ||
case _: StringValue => FlagValueType.StringValueType | ||
case _: IntValue => FlagValueType.IntValueType | ||
case _: DoubleValue => FlagValueType.DoubleValueType | ||
case _: StructureValue[_] => FlagValueType.StructureValueType | ||
} | ||
|
||
} | ||
|
||
object FlagValue { | ||
case class BooleanValue(value: Boolean) extends FlagValue | ||
case class StringValue(value: String) extends FlagValue | ||
case class IntValue(value: Int) extends FlagValue | ||
case class DoubleValue(value: Double) extends FlagValue | ||
case class StructureValue[A](value: A) extends FlagValue | ||
|
||
def apply(b: Boolean): FlagValue = BooleanValue(b) | ||
def apply(s: String): FlagValue = StringValue(s) | ||
def apply(i: Int): FlagValue = IntValue(i) | ||
def apply(d: Double): FlagValue = DoubleValue(d) | ||
def apply[A](s: A): FlagValue = StructureValue(s) | ||
} |
27 changes: 27 additions & 0 deletions
27
openfeature/sdk/src/main/scala/io/cardell/openfeature/FlagValueType.scala
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,27 @@ | ||
/* | ||
* Copyright 2023 Alex Cardell | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.cardell.openfeature | ||
|
||
sealed trait FlagValueType | ||
|
||
object FlagValueType { | ||
case object BooleanValueType extends FlagValueType | ||
case object StringValueType extends FlagValueType | ||
case object IntValueType extends FlagValueType | ||
case object DoubleValueType extends FlagValueType | ||
case object StructureValueType extends FlagValueType | ||
} |
Oops, something went wrong.