object JsonToggleMap
ToggleMaps in JSON format.
- Alphabetic
- By Inheritance
- JsonToggleMap
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed abstract class DescriptionMode extends AnyRef
How to treat the "description" field on a toggle.
How to treat the "description" field on a toggle.
- See also
- sealed abstract class DuplicateHandling extends AnyRef
How to treat the duplicate ids in arrays of toggles.
How to treat the duplicate ids in arrays of toggles.
- See also
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def mutableToJson(registry: Map[String, Mutable]): String
Serialize a ToggleMap to JSON format
Serialize a ToggleMap to JSON format
- Note
this is a helper for Java friendliness. Scala users should continue to use
toJson
.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def parse(url: URL, descriptionMode: DescriptionMode, duplicateHandling: DuplicateHandling): Try[ToggleMap]
Attempts to parse the given JSON
URL
into a ToggleMap.Attempts to parse the given JSON
URL
into a ToggleMap.Useful for loading resource files via StandardToggleMap.
The JSON Schema used is:
{ "$schema": "https://json-schema.org/draft-04/schema#", "type": "object", "required": [ "toggles" ], "properties": { "toggles": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "description": { "type": "string" }, "fraction": { "type": "number", "minimum": 0.0, "maximum": 1.0, "exclusiveMinimum": false, "exclusiveMaxmimum": false }, "comment": { "type": "string" } }, "required": [ "id", "fraction" ] } } } }
Here is an example of a JSON ToggleMap input:
{ "toggles": [ { "id": "com.game.of.thrones.WargingEnabled", "description": "Use warging for computing the response.", "fraction": 0.1 }, { "id": "com.game.of.thrones.IsWinterComing", "description": "Controls whether or not winter is coming.", "fraction": 1.0, "comment": "We've seen the white walkers, we know that winter is coming." } ] }
With the exception of "comment", the properties correspond to the various fields on Toggle.Metadata.
- name: Corresponds to
Toggle.Metadata.id
. - fraction: Corresponds to
Toggle.Metadata.fraction
and values must be between0.0
and1.0
, inclusive. - description: Corresponds to
Toggle.Metadata.description
. - comment: For documentation purposes only and is not used in the creation of the ToggleMap.
- descriptionMode
how to treat the "description" field for a toggle.
- duplicateHandling
how to handle duplicates for a toggle in same file.
- name: Corresponds to
- def parse(json: String, descriptionMode: DescriptionMode, duplicateHandling: DuplicateHandling): Try[ToggleMap]
Attempts to parse the given JSON
String
into a ToggleMap.Attempts to parse the given JSON
String
into a ToggleMap.The JSON Schema used is:
{ "$schema": "https://json-schema.org/draft-04/schema#", "type": "object", "required": [ "toggles" ], "properties": { "toggles": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "description": { "type": "string" }, "fraction": { "type": "number", "minimum": 0.0, "maximum": 1.0, "exclusiveMinimum": false, "exclusiveMaxmimum": false }, "comment": { "type": "string" } }, "required": [ "id", "fraction" ] } } } }
Here is an example of a JSON ToggleMap input:
{ "toggles": [ { "id": "com.game.of.thrones.WargingEnabled", "description": "Use warging for computing the response.", "fraction": 0.1 }, { "id": "com.game.of.thrones.IsWinterComing", "description": "Controls whether or not winter is coming.", "fraction": 1.0, "comment": "We've seen the white walkers, we know that winter is coming." } ] }
With the exception of "comment", the properties correspond to the various fields on Toggle.Metadata.
- name: Corresponds to
Toggle.Metadata.id
. - fraction: Corresponds to
Toggle.Metadata.fraction
and values must be between0.0
and1.0
, inclusive. - description: Corresponds to
Toggle.Metadata.description
. - comment: For documentation purposes only and is not used in the creation of the ToggleMap.
- descriptionMode
how to treat the "description" field for a toggle.
- duplicateHandling
how to handle duplicates for a toggle in same file.
- name: Corresponds to
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toJson(registry: Map[String, ToggleMap]): String
Serialize a ToggleMap to JSON format
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- object DescriptionIgnored extends DescriptionMode
Transforms the Toggle's "description" field into being empty.
Transforms the Toggle's "description" field into being empty.
This is useful for service owner overrides of a toggle where the developer making modifications is not the one who has defined the toggle itself.
- object DescriptionRequired extends DescriptionMode
Requires toggles to have a "description" field.
Requires toggles to have a "description" field.
This is useful for the library owner's base definitions of Toggle.
- object FailParsingOnDuplicateId extends DuplicateHandling
Requires toggles to have unique id field.
Requires toggles to have unique id field. Otherwise fail parsing.
- object KeepFirstOnDuplicateId extends DuplicateHandling
Keep the first and drop rest to remove duplicates.
Keep the first and drop rest to remove duplicates. This is useful to preserve existing behavior when new duplicate entry is added to the end of a JSON file