object ConfigDescriptor extends ConfigDescriptorFunctions
- Alphabetic
- By Inheritance
- ConfigDescriptor
- ConfigDescriptorFunctions
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
PartiallyAppliedEnumeration[D] extends AnyRef
- Definition Classes
- ConfigDescriptorFunctions
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
bigDecimal(path: String): ConfigStringModule.ConfigDescriptor[BigDecimal]
A config descriptor that describes retrieving a big-decimal from a given path.
A config descriptor that describes retrieving a big-decimal from a given path.
val mapSource = ConfigSource.fromMap( "COST" : 111111111 ) val config = bigDecimal("COST") val result = read(config from mapSource) // Right(111111111)
-
val
bigDecimal: ConfigStringModule.ConfigDescriptor[BigDecimal]
A config descriptor that describes retrieving a big-decimal.
A config descriptor that describes retrieving a big-decimal.
Note that there is no path associated with it. However, an example can give you more idea on what's going on.
val valueConfig: ConfigDescriptor[Either[BigDecimal, String]] = bigDecimal.orElseEither(string) // Describes fetching a map that is under the path "key-values" where the value of each can be either a BigDecimal or // if it's not try to fetch it as a String. An example source config val sourceString = """ { key-values : { key1 : "usa" key2 : "111111111111" key3 : "australia" } } """ val hoconSource = TypesafeConfigSource.fromHoconString(sourceString) val mapConfig = map("key-values")(valueConfig) val getMapConfig: ConfigDescriptor[Map[String, Either[BigDecimal, String]] = hoconSource.flatMap(source => read(mapConfig from source)
-
def
bigInt(path: String): ConfigStringModule.ConfigDescriptor[BigInt]
A config descriptor that describes retrieving a BigInt from a given path.
A config descriptor that describes retrieving a BigInt from a given path.
val mapSource = ConfigSource.fromMap( "COST" : 111111111 ) val config = bigInt("COST") val result = read(config from mapSource) // Right(111111111)
-
val
bigInt: ConfigStringModule.ConfigDescriptor[BigInt]
A config descriptor that describes retrieving a BigInt.
A config descriptor that describes retrieving a BigInt.
Note that there is no path associated with it. However, an example can give you more idea on what's going on.
val valueConfig: ConfigDescriptor[Either[BigInt, String]] = bigInt.orElseEither(string) // Describes fetching a map that is under the path "key-values" where the value of each can be either a BigDecimal or // if it's not try to fetch it as a String. An example source config val sourceString = """ { key-values : { key1 : "usa" key2 : "111111111111" key3 : "australia" } } """ val hoconSource = TypesafeConfigSource.fromHoconString(sourceString) val mapConfig = map("key-values")(valueConfig) val getMapConfig: ConfigDescriptor[Map[String, Either[BigInt, String]] = hoconSource.flatMap(source => read(mapConfig from source)
-
def
boolean(path: String): ConfigStringModule.ConfigDescriptor[Boolean]
A config descriptor that describes retrieving a Boolean from a given path.
A config descriptor that describes retrieving a Boolean from a given path.
val mapSource = ConfigSource.fromMap( "IS_TRUE" : true ) val config = boolean("IS_TRUE") val result = read(config from mapSource) // Right(true)
- val boolean: ConfigStringModule.ConfigDescriptor[Boolean]
-
def
byte(path: String): ConfigStringModule.ConfigDescriptor[Byte]
A config descriptor that describes retrieving a Byte from a given path.
A config descriptor that describes retrieving a Byte from a given path.
val mapSource = ConfigSource.fromMap( "KEY" : 11 ) val config = byte("KEY") val result = read(config from mapSource) // Right(11)
- val byte: ConfigStringModule.ConfigDescriptor[Byte]
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
collectAll[A](head: ⇒ ConfigStringModule.ConfigDescriptor[A], tail: ConfigStringModule.ConfigDescriptor[A]*): ConfigStringModule.ConfigDescriptor[List[A]]
collectAllis an alias tosequence.collectAllis an alias tosequence. In Functional Programming terms, it is a Traverse implementation for ConfigDescriptor. In other words, it allows us to convert aListofConfigDescriptor[A]toConfigDescriptor[List[A]].Example:
final case class Variables(variable1: Int, variable2: Option[Int]) object CollectAllExample extends App with EitherImpureOps { val listOfConfig: List[ConfigDescriptor[Variables]] = List("GROUP1", "GROUP2", "GROUP3", "GROUP4") .map( group => (int(s"${group}_VARIABLE1") zip int(s"${group}_VARIABLE2").optional).to[Variables] ) val configOfList: ConfigDescriptor[List[Variables]] = collectAll(listOfConfig.head, listOfConfig.tail: _*) val map = Map( "GROUP1_VARIABLE1" -> "1", "GROUP1_VARIABLE2" -> "2", "GROUP2_VARIABLE1" -> "3", "GROUP2_VARIABLE2" -> "4", "GROUP3_VARIABLE1" -> "5", "GROUP3_VARIABLE2" -> "6", "GROUP4_VARIABLE1" -> "7" ) // loadOrThrow here is only for the purpose of example val result: List[Variables] = read(configOfList from ConfigSource.fromMap(map, "constant")).loadOrThrow val written: PropertyTree[String, String] = write(configOfList, result).loadOrThrow assert( result == List(Variables(1, Some(2)), Variables(3, Some(4)), Variables(5, Some(6)), Variables(7, None)) )
- Definition Classes
- ConfigDescriptorFunctions
-
def
double(path: String): ConfigStringModule.ConfigDescriptor[Double]
A config descriptor that describes retrieving a Double from a given path.
A config descriptor that describes retrieving a Double from a given path.
val mapSource = ConfigSource.fromMap( "COST" : 11.11 ) val config = double("COST") val result = read(config from mapSource) // Right(11.11)
- val double: ConfigStringModule.ConfigDescriptor[Double]
-
def
duration(path: String): ConfigStringModule.ConfigDescriptor[scala.concurrent.duration.Duration]
A config descriptor that describes retrieving a duration from a given path.
A config descriptor that describes retrieving a duration from a given path.
val mapSource = ConfigSource.fromMap( "DURATION" : "3 seconds" ) val config = duration("DURATION") val result = read(config from mapSource) // Right(3 seconds)
- val duration: ConfigStringModule.ConfigDescriptor[scala.concurrent.duration.Duration]
-
def
enumeration[D]: PartiallyAppliedEnumeration[D]
enumeration allows user to up-cast all the subtypes to its super type defined by
D.enumeration allows user to up-cast all the subtypes to its super type defined by
D. This is mainly useful in definingcoproducts(sealed trait)Example:
sealed trait D case class A(a: String) extends D case class B(b: Int) extends D case class C(c: Double) extends D val config: ConfigDescriptor[D] = enumeration[D]( string("a").to[A], int("b").to[B], double("c").to[C] )
Currently enumeration supports to a maximum of 9 terms. If you have more terms, use
orElseto combine the terms.enumeration[D](a, b, c, d, e, f, g, h) orElse enumeration[D](i, j, k)
NOTE:
Use zio-config-magnolia for better compile time safety when it comes to
sealed trait, as it has strong compile time behaviour and makes sure all subtypes are being handled. On the other hand,enumerationdoesn't complain at compile time if you forgot to pass the config descriptor of any of the subtype.Example:
import zio.config.magnolia._ val config = descriptor[D]
- Definition Classes
- ConfigDescriptorFunctions
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
file(path: String): ConfigStringModule.ConfigDescriptor[File]
A config descriptor that describes retrieving a file from a given path.
A config descriptor that describes retrieving a file from a given path.
val mapSource = ConfigSource.fromMap( "FILE_PATH" : "/user/file.txt" ) val config = file("FILE_PATH") val result = read(config from mapSource) // Right(/user/file.txt)
- val file: ConfigStringModule.ConfigDescriptor[File]
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
float(path: String): ConfigStringModule.ConfigDescriptor[Float]
A config descriptor that describes retrieving a Float from a given path.
A config descriptor that describes retrieving a Float from a given path.
val mapSource = ConfigSource.fromMap( "COST" : 1.2 ) val config = float("COST") val result = read(config from mapSource) // Right(1.2f)
- val float: ConfigStringModule.ConfigDescriptor[Float]
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
head[A](path: ConfigStringModule.K)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[A]
headdescribes getting the head of a possible list valueheaddescribes getting the head of a possible list valueExample:
final case class Config(userName: String, port: Option[Int]) object Config { val source = ConfigSource.fromMap(Map("USERNAME" -> "af,sa", "PORT" -> "1"), valueDelimiter = Some(',')) val databaseConfig: ConfigDescriptor[Config] = (head("USERNAME")(string) zip int("PORT").optional).to[Config] } read(Config.databaseConfig from Config.source) // returns Config("af", 1)
- Definition Classes
- ConfigDescriptorFunctions
-
def
head[A](desc: ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[A]
headdescribes getting the head of a possible list valueheaddescribes getting the head of a possible list valueExample:
final case class Config(userName: String, port: Option[Int]) object Config { val source = ConfigSource.fromMap(Map("USERNAME" -> "af,sa", "PORT" -> "1"), valueDelimiter = Some(',')) val databaseConfig: ConfigDescriptor[Config] = (head(string("USERNAME")) zip int("PORT").optional).to[Config] } read(Config.databaseConfig from Config.source) // returns Config("af", 1)
- Definition Classes
- ConfigDescriptorFunctions
-
def
instant(path: String): ConfigStringModule.ConfigDescriptor[Instant]
A config descriptor that describes retrieving a Instant from a given path.
A config descriptor that describes retrieving a Instant from a given path.
val mapSource = ConfigSource.fromMap( "TIME" : 2020-11-24T23:21:33.034557Z ) val config = instant("TIME") val result = read(config from mapSource) // Right( 2020-11-24T23:21:33.034557Z)
- val instant: ConfigStringModule.ConfigDescriptor[Instant]
-
def
int(path: String): ConfigStringModule.ConfigDescriptor[Int]
A config descriptor that describes retrieving a Int from a given path.
A config descriptor that describes retrieving a Int from a given path.
val mapSource = ConfigSource.fromMap( "COST" : 10 ) val config = int("COST") val result = read(config from mapSource) // Right(10)
- val int: ConfigStringModule.ConfigDescriptor[Int]
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
javaFilePath(path: String): ConfigStringModule.ConfigDescriptor[Path]
A config descriptor that describes retrieving a javaFilePath from a given path.
A config descriptor that describes retrieving a javaFilePath from a given path.
val mapSource = ConfigSource.fromMap( "FILE_PATH" : "/Users/abc/xyz.txt" ) val config = javaFilePath("COST") val result = read(config from mapSource) // Right(/Users/abc/xyz.txt)
- val javaFilePath: ConfigStringModule.ConfigDescriptor[Path]
-
def
list[A](path: ConfigStringModule.K)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[List[A]]
list("xyz")(confgDescriptor)represents just a list variant of configDescriptor within the keyxyz.list("xyz")(confgDescriptor)represents just a list variant of configDescriptor within the keyxyz. Note that,nested("xyz")(list(configDescriptor))is same aslist("xyz")(configDescriptor).For example:
list("key")(string)implies value ofkeyis of the typeList[String]Here is a more detailed example.
We know
val config = string("USERNAME") from sourcerepresents a program that says, there exists a key called "USERNAME" (in some ConfigSource called source) with a value that is of the typeString.list("xyz")(config)would then imply, there exists a list ofUSERNAME -> valuepair within the key "xyz".val json = s""" | xyz : [ | { | "USERNAME" : "value1" | }, | | { | "USERNAME" : "value2" | } | ] |""".stripMargin val config = string("USERNAME") // Within the key "xyz", we have a list of key-value pair, where key is always "USERNAME" // NOTE: In HOCON, there is always a need of key (in this case, xyz) at parent level. val listConfig = list("xyz")(config) val userNames: ZIO[Any, ReadError[String], List[String]] = read(listConfig from ypesafeConfigSource.fromHoconString(json))
returns
List(value1, value2)- Definition Classes
- ConfigDescriptorFunctions
-
def
list[A](desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[List[A]]
list(confgDescriptor)represents just a list variant of configuration extraction.list(confgDescriptor)represents just a list variant of configuration extraction.For example, we know
val config = string("USERNAME") from sourcerepresents a program that says, there exists a key called "USERNAME" (in some ConfigSource called source) with a value that is of the typeString.list(config)would then imply, there exists a list ofUSERNAME -> valuepair.Given below is a complete example:
val json = s""" | xyz : [ | { | "USERNAME" : "value1" | }, | | { | "USERNAME" : "value2" | } | ] |""".stripMargin val config = string("USERNAME") // Within the key "xyz", we have a list of key-value pair, where key is always "USERNAME" // NOTE: In HOCON, there is always a need of key (in this case, xyz) at parent level. val listConfig = nested("xyz")(list(config)) val userNames: ZIO[Any, ReadError[String], List[String]] = read(listConfig from TypesafeConfigSource.fromHoconString(json))
returns
List(value1, value2)NOTE:
nested("xyz")(list(string("USERNAME"))is same aslist("xyz")(string("USERNAME"))- Definition Classes
- ConfigDescriptorFunctions
-
def
listOrSingleton[A](path: ConfigStringModule.K)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[List[A]]
listOrSingletonis a flexible version oflist.listOrSingletonis a flexible version oflist. This means, even if the value is not of the typeListit considers the value a singleton and returnsList(singleValue)We
list("xyz")(confgDescriptor)represents just a list variant of configDescriptor within the keyxyz. That islist("key")(string)implies value ofkeyis of the typeList[String]However if the value of
keywas not a list, but instead a simple string, and if we are usinglistOrSingletonit will be considered as aList.Here is a more detailed example.
val json = s""" | USERNAME : { | "USERNAME" : "abc" | } |""".stripMargin val config = string("USERNAME") val usernames: ZIO[Any, ReadError[String], List[String]] = read(listOrSingleton("configs")(config) from TypesafeConfigSource.fromHoconString(json))
returns
List(value1)- Definition Classes
- ConfigDescriptorFunctions
-
def
localDate(path: String): ConfigStringModule.ConfigDescriptor[LocalDate]
A config descriptor that describes retrieving a LocalDate from a given path.
A config descriptor that describes retrieving a LocalDate from a given path.
val mapSource = ConfigSource.fromMap( "date" : "2020-01-01" ) val config = localDate("date") val result = read(config from mapSource) // Right(2020-01-01)
- val localDate: ConfigStringModule.ConfigDescriptor[LocalDate]
-
def
localDateTime(path: String): ConfigStringModule.ConfigDescriptor[LocalDateTime]
A config descriptor that describes retrieving a LocalDateTime from a given path.
A config descriptor that describes retrieving a LocalDateTime from a given path.
val mapSource = ConfigSource.fromMap( "time" : "2020-11-25T10:26:32.482299" ) val config = localDateTime("time") val result = read(config from mapSource) // Right(2020-11-25T10:26:32.482299)
- val localDateTime: ConfigStringModule.ConfigDescriptor[LocalDateTime]
-
def
localTime(path: String): ConfigStringModule.ConfigDescriptor[LocalTime]
A config descriptor that describes retrieving a LocalTime from a given path.
A config descriptor that describes retrieving a LocalTime from a given path.
val mapSource = ConfigSource.fromMap( "LOCAL_TIME" : "10:29:02.278213" ) val config = localTime("LOCAL_TIME") val result = read(config from mapSource) // Right(10:29:02.278213)
- val localTime: ConfigStringModule.ConfigDescriptor[LocalTime]
-
def
long(path: String): ConfigStringModule.ConfigDescriptor[Long]
A config descriptor that describes retrieving a Long from a given path.
A config descriptor that describes retrieving a Long from a given path.
val mapSource = ConfigSource.fromMap( "COST" : 111111111 ) val config = long("COST") val result = read(config from mapSource) // Right(111111111)
- val long: ConfigStringModule.ConfigDescriptor[Long]
-
def
map[A](path: ConfigStringModule.K)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[Map[ConfigStringModule.K, A]]
map("xyz")(confgDescriptor)represents retrieving a map (of key value pairs) that exists within the key "xyz"map("xyz")(confgDescriptor)represents retrieving a map (of key value pairs) that exists within the key "xyz"Let's explain this in detail with an example: int("URL") implies there exists a value of the type string under the key "URL" On similar lines, map("URL")(int) implies there exists a value of the type
Mapunder the keyURLand the type of the value of each key in the map is of the type Int.Sidee note: Obviously, for complex types such as Map, you can also rely on zio-config-magnolia that allows you to retrieve any value of the type Map[String, A] for all type A, that has an instance of
Description(refer zio-config-magnolia api docs)val config = map("xyz")(int) val source: ConfigSource = TypesafeConfigSource.fromHoconString( "xyz" : { "key1" : "1" "key2" : "2" "key3" : "3" } ) // Forming a TypesafeConfigSource from string returned an Either (being able to capture errors) because // the HOCON string can be an invalid string. val result = read(config from source) // Right(Map("key1" -> 1, "key2" -> 2, "key3" -> 3))
We explained
mapusing TypesafeConfigSource. However, for zio-config source doesn't really matter. For example, lets try to fetch a map from a flattened scala Map.val source = ConfigSource.fromMap( Map( "xyz_key1" -> "1", "xyz_key2" -> "2", "xyz_key3" -> "3" ), keyDelimiter = Some('_') ) val config = read(config from source) // Right( Map("key1" -> 1, "key2" -> 2, "key3" -> 3))
- Definition Classes
- ConfigDescriptorFunctions
-
def
map[A](desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[Map[ConfigStringModule.K, A]]
Retrieve a
Mapgiven an existingConfigDescriptor.Retrieve a
Mapgiven an existingConfigDescriptor.map(configDescriptor)is similar tomap(path)(configDescriptor)except that there is nopathassociated with it. For the same reason, you would need the second version given below:def map[A](path: K)(desc: => ConfigDescriptor[A])Before we try to understand the semantics of
map(configDescriptor), let's understand the semantics ofmap(path)(configDescriptor); a function with the same name given below, but it takes a path as well.map("xyz")(confgDescriptor)represents retrieving a map (of key value pairs) that exists within the key "xyz"Let's explain this in detail with an example: int("URL") implies there exists a value of the type string under the key "URL" On similar lines, map("URL")(int) implies there exists a value of the type
Mapunder the keyURLand the type of the value of each key in the map is of the type Int.Sidee note: Obviously, for complex types such as Map, you can also rely on zio-config-magnolia that allows you to retrieve any value of the type Map[String, A] for all type A, that has an instance of
Description(refer zio-config-magnolia api docs)val config = map("xyz")(int) val source: ConfigSource = TypesafeConfigSource.fromHoconString( "xyz" : { "key1" : "1" "key2" : "2" "key3" : "3" } ) // Forming a TypesafeConfigSource from string returned an Either (being able to capture errors) because // the HOCON string can be an invalid string. val result = sourceOrFailed.flatMap(source => read(config from source)) // Map("key1" -> 1, "key2" -> 2, "key3" -> 3)
We explained
mapusing TypesafeConfigSource. However, for zio-config source doesn't really matter. For example, lets try to fetch a map from a flattened scala Map.val source = ConfigSource.fromMap( Map( "xyz_key1" -> "1", "xyz_key2" -> "2", "xyz_key3" -> "3" ), keyDelimiter = Some('_') ) val config = read(config from source) // Map("key1" -> 1, "key2" -> 2, "key3" -> 3)
Now what does it mean if we say
val config = map(int("id"))instead ofval config = map("id")(int)The difference is
map("id")(int)implies there exists a map within the keyid, whose values of are of the typeIntOn the other handmap(int("id"))implies there exists a map hose value is of the type {"id" : "Int"}Example:
val mapConfig = map(int("id")) // This means there exists a Map whose value is of the type {"String" : "Int"}. val sourceOrFailure: ConfigSource = TypesafeConfigSource.fromHoconString( s""" "abc" : { "key1" : { "id" : "2" }, "key2" : { "id" : "3" } } """" ) val result = read(nested("abc")(map(int("id"))) from source) // Map("key1" -> 1, "key2" -> 2)
This is really useful when the config source consist of a map but you need to fetch the value of the keys in the map from an nested key within itself. In this example it is "id".
- Definition Classes
- ConfigDescriptorFunctions
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nested[A](path: ConfigStringModule.K)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A], keyType: Option[KeyType] = None): ConfigStringModule.ConfigDescriptor[A]
nested allows us to retrieve a config from a path
K, whereKis typicallyString.nested allows us to retrieve a config from a path
K, whereKis typicallyString.Example :
val config = nested("key")(string) val mapSource = ConfigSource.fromMap( "key" : "value" ) val result = read(config from mapSource) // "value"
Note that
string("key")is same as that ofnested("key")(string)- Definition Classes
- ConfigDescriptorFunctions
-
def
nonEmptyChunk[A](path: String)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[NonEmptyChunk[A]]
Similar to
listhowever the size of the values shouldn't be zeroSimilar to
listhowever the size of the values shouldn't be zero- Definition Classes
- ConfigDescriptorFunctions
-
def
nonEmptyChunk[A](desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[NonEmptyChunk[A]]
Similar to
listhowever the size of the values shouldn't be zeroSimilar to
listhowever the size of the values shouldn't be zero- Definition Classes
- ConfigDescriptorFunctions
-
def
nonEmptyChunkOrSingleton[A](path: String)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[NonEmptyChunk[A]]
Similar to
listhowever the size of the values shouldn't be zero.Similar to
listhowever the size of the values shouldn't be zero. Also it can accept a singleton value as a NonEmptyChunk- Definition Classes
- ConfigDescriptorFunctions
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
set[A](path: ConfigStringModule.K)(desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[Set[A]]
set("xyz")(confgDescriptor)represents just a set variant of configDescriptor within the keyxyz.set("xyz")(confgDescriptor)represents just a set variant of configDescriptor within the keyxyz. Note that,nested("xyz")(set(configDescriptor))is same asset("xyz")(configDescriptor).For example:
set("key")(string)implies value ofkeyis of the typeSet[String]Here is a more detailed example.
list("xyz")(string)would then imply, there exists a set of type String under "xyz"val json = s""" | xyz : ["a", "b"] |""".stripMargin val source: ConfigSource = TypesafeConfigSource.fromHoconString(json) read(set("xyz")(string) from source)
returns
List(value1, value2)- Definition Classes
- ConfigDescriptorFunctions
-
def
set[A](desc: ⇒ ConfigStringModule.ConfigDescriptor[A]): ConfigStringModule.ConfigDescriptor[Set[A]]
set("xyz")(confgDescriptor)represents just a set variant of configDescriptor within the keyxyz.set("xyz")(confgDescriptor)represents just a set variant of configDescriptor within the keyxyz. Note that,nested("xyz")(set(configDescriptor))is same asset("xyz")(configDescriptor).For example:
set("key")(string)implies value ofkeyis of the typeSet[String]Here is a more detailed example.
list("xyz")(string)would then imply, there exists a set of type String under "xyz"val json = s""" | xyz : ["a", "b"] |""".stripMargin val source: ConfigSource = TypesafeConfigSource.fromHoconString(json) read(set("xyz")(string) from source)
returns
Right(List(value1, value2))- Definition Classes
- ConfigDescriptorFunctions
-
def
short(path: String): ConfigStringModule.ConfigDescriptor[Short]
A config descriptor that describes retrieving a Short from a given path.
A config descriptor that describes retrieving a Short from a given path.
val mapSource = ConfigSource.fromMap( "ID" : "1" ) val config = short("ID") val result = read(config from mapSource) // Right(1)
- val short: ConfigStringModule.ConfigDescriptor[Short]
-
def
string(path: String): ConfigStringModule.ConfigDescriptor[String]
A config descriptor that describes retrieving a String from a given path.
A config descriptor that describes retrieving a String from a given path.
val mapSource = ConfigSource.fromMap( "COUNTRY" : "Australia" ) val config = string("COUNTRY") val result = read(config from mapSource) // Right(Australia)
- val string: ConfigStringModule.ConfigDescriptor[String]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
uri(path: String): ConfigStringModule.ConfigDescriptor[URI]
A config descriptor that describes retrieving a Uri from a given path.
A config descriptor that describes retrieving a Uri from a given path.
val mapSource = ConfigSource.fromMap( "URI" : "www.bla.com" ) val config = uri("URI") val result = read(config from mapSource) // Right(www.bla.com)
- val uri: ConfigStringModule.ConfigDescriptor[URI]
-
def
url(path: String): ConfigStringModule.ConfigDescriptor[URL]
A config descriptor that describes retrieving a Url from a given path.
A config descriptor that describes retrieving a Url from a given path.
val mapSource = ConfigSource.fromMap( "URL" : "www.bla.com" ) val config = bigInt("COST") val result = read(config from mapSource) // Right(111111111)
- val url: ConfigStringModule.ConfigDescriptor[URL]
-
def
uuid(path: String): ConfigStringModule.ConfigDescriptor[UUID]
A config descriptor that describes retrieving a Uuid from a given path.
A config descriptor that describes retrieving a Uuid from a given path.
val mapSource = ConfigSource.fromMap( "ID" : "a0f25f26-95b3-4124-8f7f-67fb04f714b7" ) val config = uuid("ID") val result = read(config from mapSource) // Right(a0f25f26-95b3-4124-8f7f-67fb04f714b7)
- val uuid: ConfigStringModule.ConfigDescriptor[UUID]
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
zioDuration(path: String): ConfigStringModule.ConfigDescriptor[java.time.Duration]
A config descriptor that describes retrieving a zioDuration from a given path.
A config descriptor that describes retrieving a zioDuration from a given path.
val mapSource = ConfigSource.fromMap( "DURATION" : "3 seconds" ) val config = zioDuration("DURATION") val result = read(config from mapSource) // Right(PT3S)
- val zioDuration: ConfigStringModule.ConfigDescriptor[java.time.Duration]