trait Config extends AnyRef
API for retrieving configuration values based on a string key and a decoder.
Config instances are used in many places in this library, each Document
,
DocumentTree
and Directive
has a Config instance associated with it.
One use case for configuration is controlling the behaviour of built-in features, like setting the navigation order or the depth for table of contents.
A second use case is user configuration, where custom variables can be set
in configuration files or headers and then referenced in templates or markup
with the syntax ${ref.path}
.
The key is a path separated by '.', which allows to reference nested objects in the configuration.
Built-in decoders are available for simple types like String
, Int
, Double
, Boolean
and any Seq
consisting of those values.
It also comes with a decoder for Path
, which resolves relative paths in the configuration
against the (virtual) path of the origin.
This API is usually used with values obtained by parsing HOCON, as specified in https://github.com/lightbend/config/blob/master/HOCON.md, but the API is generic and can also be used with values specified programmatically.
Please note that Laika does not depend on the Typesafe Config library or any of its commonly used Scala wrappers or forks. It has its own HOCON parser, which implements the full spec while still being minimal and lightweight. It also ensures the FP properties are kept intact, e.g. it has full referential transparency and does not throw Exceptions like most of the alternatives.
- Alphabetic
- By Inheritance
- Config
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
get[T](key: Key)(implicit decoder: ConfigDecoder[T]): ConfigResult[T]
Retrieve a required value for the specified key and decoder.
-
abstract
def
hasKey(key: Key): Boolean
Verifies whether this config instance contains a value mapped to the specified key.
-
abstract
def
origin: Origin
The origin of this configuration, which might come from programmatic configuration, a file in one of the input directories, a configuration header in a markup document or from an attribute section in a directive.
-
abstract
def
withFallback(other: Config): Config
Returns a new configuration instance using the specified instance as a fallback for keys not found in this instance.
Returns a new configuration instance using the specified instance as a fallback for keys not found in this instance.
If this instance already has a fallback, the new fallback will be passed further down the chain.
-
abstract
def
withOrigin(origin: Origin): Config
Returns a new configuration instance using the specified origin.
Concrete 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( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
get[T](implicit decoder: ConfigDecoder[T], defaultKey: DefaultKey[T]): ConfigResult[T]
Retrieve a required value for the specified implicit key and decoder.
Retrieve a required value for the specified implicit key and decoder.
A defaultKey can be used for commonly used configuration objects like
AutonumberConfig
that are expected to be mapped to a specific key, likeautonumbering
. -
def
get[T](key: String, default: ⇒ T)(implicit decoder: ConfigDecoder[T]): ConfigResult[T]
Retrieve an optional value for the specified key and decoder, falling back to the given default if the value is missing.
-
def
get[T](key: Key, default: ⇒ T)(implicit decoder: ConfigDecoder[T]): ConfigResult[T]
Retrieve an optional value for the specified key and decoder, falling back to the given default if the value is missing.
-
def
get[T](key: String)(implicit decoder: ConfigDecoder[T]): ConfigResult[T]
Retrieve a required value for the specified key and decoder.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
getOpt[T](key: String)(implicit decoder: ConfigDecoder[T]): ConfigResult[Option[T]]
Retrieve an optional value for the specified key and decoder.
Retrieve an optional value for the specified key and decoder. The result is still an Either as this method might still fail even if the value is present in case the decoding fails.
-
def
getOpt[T](implicit decoder: ConfigDecoder[T], defaultKey: DefaultKey[T]): ConfigResult[Option[T]]
Retrieve an optional value for the specified implicit key and decoder.
Retrieve an optional value for the specified implicit key and decoder.
A defaultKey can be used for commonly used configuration objects like
AutonumberConfig
that are expected to be mapped to a specific key, likeautonumbering
.The result is still an Either as this method might still fail even if the value is present in case the decoding fails.
-
def
getOpt[T](key: Key)(implicit decoder: ConfigDecoder[T]): ConfigResult[Option[T]]
Retrieve an optional value for the specified key and decoder.
Retrieve an optional value for the specified key and decoder. The result is still an Either as this method might still fail even if the value is present in case the decoding fails.
-
def
hasKey(key: String): Boolean
Verifies whether this config instance contains a value mapped to the specified key.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
withValue[T](value: T)(implicit encoder: ConfigEncoder[T], defaultKey: DefaultKey[T]): ConfigBuilder
Creates a new configuration builder with the specified value and this instance as a fallback.
Creates a new configuration builder with the specified value and this instance as a fallback. The returned builder can be used to add further values before calling
build
to retrieve a new instance. -
def
withValue[T](key: Key, value: T)(implicit encoder: ConfigEncoder[T]): ConfigBuilder
Creates a new configuration builder with the specified value and this instance as a fallback.
Creates a new configuration builder with the specified value and this instance as a fallback. The returned builder can be used to add further values before calling
build
to retrieve a new instance. -
def
withValue[T](key: String, value: T)(implicit encoder: ConfigEncoder[T]): ConfigBuilder
Creates a new configuration builder with the specified value and this instance as a fallback.
Creates a new configuration builder with the specified value and this instance as a fallback. The returned builder can be used to add further values before calling
build
to retrieve a new instance.
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated