Interface ConfigurationQueryResult

All Known Implementing Classes:
CompositeConfigurationSource.CompositeConfigurationQueryResult, io.inverno.mod.configuration.internal.GenericConfigurationQueryResult, VersionedRedisConfigurationSource.VersionedRedisConfigurationQueryResult

public interface ConfigurationQueryResult

Represents a single query result providing the configuration property retrieved from a configuration source with a query key.

Note that the query key and the property key may differs if the configuration source uses a defaulting mechanism to return the value that best matches the context specified in the query key.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    as(Class<T> type, T defaultValue)
    Returns the configuration property value converted to the specified type or a default value.
    <T> T
    as(Type type, T defaultValue)
    Returns the configuration property value converted to the specified type or a default value.
    <T> T[]
    asArrayOf(Class<T> type, T[] defaultValue)
    Returns the configuration property value converted to an array of the specified type or a default array.
    <T> T[]
    asArrayOf(Type type, T[] defaultValue)
    Returns the configuration property value converted to an array of the specified type or a default array.
    asBigDecimal(BigDecimal defaultValue)
    Returns the configuration property value as a big decimal or a default value.
    asBigInteger(BigInteger defaultValue)
    Returns the configuration property value as a big integer or a default value.
    boolean
    asBoolean(boolean defaultValue)
    Returns the configuration property value as a boolean or a default value.
    byte
    asByte(byte defaultValue)
    Returns the configuration property value as a byte or a default value.
    char
    asCharacter(char defaultValue)
    Returns the configuration property value as a character or a default value.
    <T> Class<T>
    asClass(Class<T> defaultValue)
    Returns the configuration property value as a class or a default value.
    asCurrency(Currency defaultValue)
    Returns the configuration property value as a currency or a default value.
    double
    asDouble(double defaultValue)
    Returns the configuration property value as a double or a default value.
    asFile(File defaultValue)
    Returns the configuration property value as a file or a default value.
    float
    asFloat(float defaultValue)
    Returns the configuration property value as a float or a default value.
    asInetAddress(InetAddress defaultValue)
    Returns the configuration property value as an inet address or a default value.
    Returns the configuration property value as an inet socket address or a default value.
    int
    asInteger(int defaultValue)
    Returns the configuration property value as an integer or a default value.
    <T> List<T>
    asListOf(Class<T> type, List<T> defaultValue)
    Returns the configuration property value converted to a list of the specified type or a default list.
    <T> List<T>
    asListOf(Type type, List<T> defaultValue)
    Returns the property value converted to a list of the specified type or a default list.
    asLocalDate(LocalDate defaultValue)
    Returns the configuration property value as a local date or a default value.
    Returns the configuration property value as a local date time or a default value.
    asLocale(Locale defaultValue)
    Returns the configuration property value as a locale or a default value.
    long
    asLong(long defaultValue)
    Returns the configuration property value as a long or a default value.
    asPath(Path defaultValue)
    Returns the configuration property value as a path or a default value.
    asPattern(Pattern defaultValue)
    Returns the configuration property value as a pattern or a default value.
    <T> Set<T>
    asSetOf(Class<T> type, Set<T> defaultValue)
    Returns the configuration property value converted to a set of the specified type or a default set.
    <T> Set<T>
    asSetOf(Type type, Set<T> defaultValue)
    Returns the configuration property value converted to a set of the specified type or a default set.
    short
    asShort(short defaultValue)
    Returns the configuration property value as a short or a default value.
    asString(String defaultValue)
    Returns the configuration property value as a string or a default value.
    asURI(URI defaultValue)
    Returns the configuration property value as a URI or a default value.
    asURL(URL defaultValue)
    Returns the configuration property value as a URL or a default value.
    Returns the configuration property value as a zoned date time or a default value.
    get()
    Returns the resulting configuration property.
    Returns the configuration key corresponding to the query that was executed.
    void
    Performs the given action with the configuration property if a result is present, otherwise does nothing.
    void
    ifPresentOrElse(Consumer<? super ConfigurationProperty> action, Runnable emptyAction)
    Performs the given action with the configuration property if a result is present, otherwise performs the given empty-based action.
    boolean
    Determines whether the result is empty.
    boolean
    Determines whether the result is present.
    Returns the configuration property if a result is present, otherwise throws NoSuchElementException.
    orElseThrow(Supplier<? extends X> exceptionSupplier)
    Returns the configuration property if a result is present, otherwise throws an exception produced by the exception supplying function.
    Returns the query result as configuration property Optional.
  • Method Details

    • getQueryKey

      ConfigurationKey getQueryKey()

      Returns the configuration key corresponding to the query that was executed.

      Returns:
      a configuration key
    • isPresent

      boolean isPresent()

      Determines whether the result is present.

      An actual result is returned when a property has been defined in the target source for the queried key. Note that this doesn't mean the property has a non-null value since null values are supported.

      Returns:
      true if there is a result, false otherwise
    • isEmpty

      boolean isEmpty()

      Determines whether the result is empty.

      No result is returned when no property has been defined in the target source for the queried key.

      Returns:
      true if there is no result, false otherwise
    • ifPresent

      void ifPresent(Consumer<? super ConfigurationProperty> action)

      Performs the given action with the configuration property if a result is present, otherwise does nothing.

      Parameters:
      action - the action to be performed if a result is present
    • ifPresentOrElse

      void ifPresentOrElse(Consumer<? super ConfigurationProperty> action, Runnable emptyAction)

      Performs the given action with the configuration property if a result is present, otherwise performs the given empty-based action.

      Parameters:
      action - the action to be performed if a result is present
      emptyAction - the empty-based action to be performed if no result is present
    • orElseThrow

      Returns the configuration property if a result is present, otherwise throws NoSuchElementException.

      Returns:
      the configuration property
      Throws:
      NoSuchElementException - if no result is present
    • orElseThrow

      <X extends Throwable> ConfigurationProperty orElseThrow(Supplier<? extends X> exceptionSupplier) throws X

      Returns the configuration property if a result is present, otherwise throws an exception produced by the exception supplying function.

      Type Parameters:
      X - the type of the exception to be thrown
      Parameters:
      exceptionSupplier - the exception supplier
      Returns:
      the configuration property
      Throws:
      X - if no result is present
    • get

      Returns the resulting configuration property.

      Returns:
      the configuration property
      Throws:
      ConfigurationSourceException - if there was an error retrieving the configuration property
      NoSuchElementException - if the result is empty
    • as

      <T> T as(Class<T> type, T defaultValue)

      Returns the configuration property value converted to the specified type or a default value.

      Type Parameters:
      T - the target type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • as

      <T> T as(Type type, T defaultValue)

      Returns the configuration property value converted to the specified type or a default value.

      Type Parameters:
      T - the target type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asArrayOf

      <T> T[] asArrayOf(Class<T> type, T[] defaultValue)

      Returns the configuration property value converted to an array of the specified type or a default array.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default array
    • asArrayOf

      <T> T[] asArrayOf(Type type, T[] defaultValue)

      Returns the configuration property value converted to an array of the specified type or a default array.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default array
    • asListOf

      <T> List<T> asListOf(Class<T> type, List<T> defaultValue)

      Returns the configuration property value converted to a list of the specified type or a default list.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default list
    • asListOf

      <T> List<T> asListOf(Type type, List<T> defaultValue)

      Returns the property value converted to a list of the specified type or a default list.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default list
    • asSetOf

      <T> Set<T> asSetOf(Class<T> type, Set<T> defaultValue)

      Returns the configuration property value converted to a set of the specified type or a default set.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default set
    • asSetOf

      <T> Set<T> asSetOf(Type type, Set<T> defaultValue)

      Returns the configuration property value converted to a set of the specified type or a default set.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default set
    • asByte

      byte asByte(byte defaultValue)

      Returns the configuration property value as a byte or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asShort

      short asShort(short defaultValue)

      Returns the configuration property value as a short or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asInteger

      int asInteger(int defaultValue)

      Returns the configuration property value as an integer or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asLong

      long asLong(long defaultValue)

      Returns the configuration property value as a long or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asFloat

      float asFloat(float defaultValue)

      Returns the configuration property value as a float or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asDouble

      double asDouble(double defaultValue)

      Returns the configuration property value as a double or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asCharacter

      char asCharacter(char defaultValue)

      Returns the configuration property value as a character or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asString

      String asString(String defaultValue)

      Returns the configuration property value as a string or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asBoolean

      boolean asBoolean(boolean defaultValue)

      Returns the configuration property value as a boolean or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asBigInteger

      BigInteger asBigInteger(BigInteger defaultValue)

      Returns the configuration property value as a big integer or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asBigDecimal

      BigDecimal asBigDecimal(BigDecimal defaultValue)

      Returns the configuration property value as a big decimal or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asLocalDate

      LocalDate asLocalDate(LocalDate defaultValue)

      Returns the configuration property value as a local date or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asLocalDateTime

      LocalDateTime asLocalDateTime(LocalDateTime defaultValue)

      Returns the configuration property value as a local date time or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asZonedDateTime

      ZonedDateTime asZonedDateTime(ZonedDateTime defaultValue)

      Returns the configuration property value as a zoned date time or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asCurrency

      Currency asCurrency(Currency defaultValue)

      Returns the configuration property value as a currency or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asLocale

      Locale asLocale(Locale defaultValue)

      Returns the configuration property value as a locale or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asFile

      File asFile(File defaultValue)

      Returns the configuration property value as a file or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asPath

      Path asPath(Path defaultValue)

      Returns the configuration property value as a path or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asURI

      URI asURI(URI defaultValue)

      Returns the configuration property value as a URI or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asURL

      URL asURL(URL defaultValue)

      Returns the configuration property value as a URL or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asPattern

      Pattern asPattern(Pattern defaultValue)

      Returns the configuration property value as a pattern or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asInetAddress

      InetAddress asInetAddress(InetAddress defaultValue)

      Returns the configuration property value as an inet address or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asInetSocketAddress

      InetSocketAddress asInetSocketAddress(InetSocketAddress defaultValue)

      Returns the configuration property value as an inet socket address or a default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • asClass

      <T> Class<T> asClass(Class<T> defaultValue)

      Returns the configuration property value as a class or a default value.

      Type Parameters:
      T - the target type
      Parameters:
      defaultValue - a default value
      Returns:
      the configuration property value or the specified default value
    • toOptional

      Returns the query result as configuration property Optional.

      This method allows to map the query result as an Optional.

      Returns:
      an optional returning the configuration property or an empty optional if the configuration returned no value for the property
      Throws:
      ConfigurationSourceException - if there was an error retrieving the configuration property