Interface ConfigValue<T>

Type Parameters:
T - type of the value
All Superinterfaces:
ConfigValue<T>, io.helidon.common.mapper.OptionalValue<T>, io.helidon.common.mapper.Value<T>

public interface ConfigValue<T> extends ConfigValue<T>
A typed value of a Config node.

You can use accessor methods on Config to obtain this value, such as Config.as(Class). A typed value that has all the methods of Optional - including the ones added in JDK9 and newer. In addition it has methods to access config values as supplier().

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <N> ConfigValue<N>
    as(Function<? super T,? extends N> mapper)
    Convert this ConfigValue to a different type using a mapper function.
    default T
    get()
    Typed value of the represented Config node.
    key()
    Returns the fully-qualified key of the originating Config node.
    default String
    Returns the last token of the fully-qualified key for the originating Config node.
    Returns a Supplier of an Optional<T> of the configuration node.
    Returns a supplier of a typed value.
    supplier(T defaultValue)
    Returns a supplier of a typed value with a default.

    Methods inherited from interface io.helidon.common.config.ConfigValue

    as, as

    Methods inherited from interface io.helidon.common.mapper.OptionalValue

    asBoolean, asDouble, asInt, asLong, asString, ifPresent, ifPresentOrElse, isEmpty, isPresent, map, or, orElse, orElseGet, orElseThrow, orElseThrow

    Methods inherited from interface io.helidon.common.mapper.Value

    asOptional, filter, flatMap, get, get, getBoolean, getDouble, getInt, getLong, getString, stream
  • Method Details

    • key

      Config.Key key()
      Returns the fully-qualified key of the originating Config node.

      The fully-qualified key is a sequence of tokens derived from the name of each node along the path from the config root to the current node. Tokens are separated by . (the dot character). See name() for more information on the format of each token.

      Specified by:
      key in interface ConfigValue<T>
      Returns:
      current config node key
      See Also:
    • name

      default String name()
      Returns the last token of the fully-qualified key for the originating Config node.

      The name of a node is the last token in its fully-qualified key.

      The exact format of the name depends on the Type of the containing node:

      • from a Config.Type.OBJECT node the token for a child is the name of the object member;
      • from a Config.Type.LIST node the token for a child is a zero-based index of the element, an unsigned base-10 integer value with no leading zeros.

      The ABNF syntax of config key is:

      
       config-key = *1( key-token *( "." key-token ) )
        key-token = *( unescaped / escaped )
        unescaped = %x00-2D / %x2F-7D / %x7F-10FFFF
                  ; %x2E ('.') and %x7E ('~') are excluded from 'unescaped'
          escaped = "~" ( "0" / "1" )
                  ; representing '~' and '.', respectively
       
      Specified by:
      name in interface ConfigValue<T>
      Specified by:
      name in interface io.helidon.common.mapper.Value<T>
      Returns:
      current config node key
      See Also:
    • get

      Typed value of the represented Config node. Throws MissingValueException if the node is Config.Type.MISSING type.
      Specified by:
      get in interface io.helidon.common.mapper.OptionalValue<T>
      Specified by:
      get in interface io.helidon.common.mapper.Value<T>
      Returns:
      direct value of this node converted to the expected type
      Throws:
      MissingValueException - in case the node is Config.Type.MISSING.
      ConfigMappingException - in case the value cannot be converted to the expected type
    • as

      <N> ConfigValue<N> as(Function<? super T,? extends N> mapper)
      Convert this ConfigValue to a different type using a mapper function.
      Specified by:
      as in interface ConfigValue<T>
      Specified by:
      as in interface io.helidon.common.mapper.OptionalValue<T>
      Specified by:
      as in interface io.helidon.common.mapper.Value<T>
      Type Parameters:
      N - type of the returned ConfigValue
      Parameters:
      mapper - mapper to map the type of this ConfigValue to a type of the returned ConfigValue
      Returns:
      a new value with the new type
    • supplier

      Supplier<T> supplier()
      Returns a supplier of a typed value. The value provided from the supplier is the latest value available. E.g. in case there is a file config source that is being watched and a value is changed, this supplier would return the latest value, whereas get() would return the original value.

      Note that Supplier.get() can throw a ConfigMappingException or MissingValueException as the get() method.

      Specified by:
      supplier in interface ConfigValue<T>
      Returns:
      a supplier of a typed value
    • supplier

      Supplier<T> supplier(T defaultValue)
      Returns a supplier of a typed value with a default. The value provided from the supplier is the latest value available. E.g. in case there is a file config source that is being watched and a value is changed, this supplier would return the latest value, whereas OptionalValue.orElse(Object) would return the original value.

      Note that Supplier.get() can throw a ConfigMappingException as the OptionalValue.orElse(Object) method.

      Specified by:
      supplier in interface ConfigValue<T>
      Parameters:
      defaultValue - a value to be returned if the supplied value represents a Config node that has no direct value
      Returns:
      a supplier of a typed value
    • optionalSupplier

      Supplier<Optional<T>> optionalSupplier()
      Returns a Supplier of an Optional<T> of the configuration node. Supplier returns a empty if the node does not have a direct value.
      Specified by:
      optionalSupplier in interface ConfigValue<T>
      Returns:
      a supplier of the value as an Optional typed instance, empty in case the node does not have a direct value
      See Also: