Class/Object

com.fulcrumgenomics.commons.util

Configuration

Related Docs: object Configuration | package util

Permalink

class Configuration extends ConfigurationLike

Class that provides useful methods for resolving all kinds of things in configuration. Uses Config to retrieve configuration values in a type-safe way.

The requestedKeys method returns all the keys requested.

The public methods to retrieve values are the apply, get, and getOrElse methods.

Examples:
  1. A common pattern is to create an object that extends this class, and reference that object when retrieving values from a path. An additional trait is created that references the custom configuration object, allowing other classes to mix in the additional trait to get access the the configuration methods that use the custom configuration object.

    scala> import com.fulcrumgenomics.commons.util.{Configuration, ConfigurationLike}
    scala> import com.typesafe.config.{Config, ConfigFactory}
    scala> // create an object that stores the config that will be referenced everywhere
    scala> object CustomConfiguration extends Configuration(ConfigFactory.load())
    scala> // create the trait that can be mixed into other classes to get access to the configuration methods that use the custom configuration object
    scala> trait CustomConfiguration extends ConfigurationLike { protected def config: Config = CustomConfiguration.config }
    scala> // create a class that mixes in the custom configuration trait
    scala> class Foo extends CustomConfiguration { val maybeLong: Option[Long] = this.get[Long]("path.does-not-exist") }
    scala> val foo = new Foo()
    scala> foo.maybeLong
    res0: Option[Long] = None
    scala> foo.get("path.does-not-exist")
    res1: Option[Long] = None
    scala> foo[Long]("path.does-exists-and-is-1")
    res2: Long = 1
    scala> foo.getOrElse[Long]("path.does-not-exist", 2)
    res3: Long = 2
  2. ,
  3. A common pattern is to create an object that extends this class, and reference that object when retrieving values from a path.

    scala> import com.fulcrumgenomics.commons.util.Configuration
    scala> import com.typesafe.config.{Config, ConfigFactory}
    scala> object CustomConfiguration extends Configuration(ConfigFactory.load())
    scala> CustomConfiguration.get[Long]("path.does-not-exist")
    res0: Option[Long] = None
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Configuration
  2. ConfigurationLike
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Configuration(config: Config)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to any2stringadd[Configuration] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Configuration, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to ArrowAssoc[Configuration] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. def apply[T](path: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T

    Permalink

    Looks up a single value of a specific type in configuration.

    Looks up a single value of a specific type in configuration. If the configuration key does not exist, an exception is thrown. If the requested type is not supported, an exception is thrown.

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def asType[T](path: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T

    Permalink

    Converts the configuration path to the given type.

    Converts the configuration path to the given type. If the requested type is not supported, an exception is thrown. Override this method to support custom types.

    Attributes
    protected
    Definition Classes
    ConfigurationLike
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. val config: Config

    Permalink

    The configuration to query.

    The configuration to query.

    Attributes
    protected
    Definition Classes
    ConfigurationConfigurationLike
  11. def ensuring(cond: (Configuration) ⇒ Boolean, msg: ⇒ Any): Configuration

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to Ensuring[Configuration] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: (Configuration) ⇒ Boolean): Configuration

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to Ensuring[Configuration] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean, msg: ⇒ Any): Configuration

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to Ensuring[Configuration] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean): Configuration

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to Ensuring[Configuration] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  17. def fetch[T](path: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): Option[T]

    Permalink

    Method to fetch a configuration key that may or may not be present.

    Method to fetch a configuration key that may or may not be present.

    Attributes
    protected
    Definition Classes
    ConfigurationLike
  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to StringFormat[Configuration] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  20. def get[T](path: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): Option[T]

    Permalink

    Optionally accesses a configuration value.

    Optionally accesses a configuration value. If the value is not present in the configuration a None will be returned, else a Some(T) of the appropriate type.

  21. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  22. def getOrElse[T](path: String, default: ⇒ T)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T

    Permalink

    Optionally accesses a configuration value.

    Optionally accesses a configuration value. If the value is not present in the configuration a the default value will be returned.

  23. def handle(message: ⇒ String, throwable: Option[Throwable] = None): Nothing

    Permalink

    Method to allow subclasses to override how errors are handled, e.g.

    Method to allow subclasses to override how errors are handled, e.g. by logging or throwing different exceptions.

    Attributes
    protected
    Definition Classes
    ConfigurationLike
  24. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  26. def keyRequested(path: String): Unit

    Permalink

    Method that can be overridden to receive a call each time a configuration path is requested.

    Method that can be overridden to receive a call each time a configuration path is requested.

    Attributes
    protected
    Definition Classes
    ConfigurationConfigurationLike
  27. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  28. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  30. def requestedKeys: SortedSet[String]

    Permalink

    Returns a sorted set of all keys that have been requested up to this point in time.

  31. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  32. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  33. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. def [B](y: B): (Configuration, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Configuration to ArrowAssoc[Configuration] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from ConfigurationLike

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Configuration to any2stringadd[Configuration]

Inherited by implicit conversion StringFormat from Configuration to StringFormat[Configuration]

Inherited by implicit conversion Ensuring from Configuration to Ensuring[Configuration]

Inherited by implicit conversion ArrowAssoc from Configuration to ArrowAssoc[Configuration]

Ungrouped