Interface ConfigurationProperty


public interface ConfigurationProperty

A configuration property.

A configuration property is identified by a configuration key which is composed of a name and a collection of parameters defining the context for which a property value is defined. This means that for a given property name, multiple values can be defined in a configuration source for different contexts.

Author:
Jeremy Kuhn
See Also:
  • Method Details

    • getKey

      Returns the key identifying the property and the context in which it has been defined.

      Returns:
      a configuration key
    • getSource

      ConfigurationSource getSource()

      Returns the configuration source that loaded the property.

      Returns:
      a configuration source.
    • isUnset

      boolean isUnset()

      Determines whether this property is unset.

      Unset properties are always empty, they are used in a CompositeConfigurationSource to cancel non-empty properties retrieved from sources with lower priority.

      Returns:
      true if the property is unset, false otherwise
    • isPresent

      boolean isPresent()

      Determines whether the value is present (ie. value is not null).

      Returns:
      true if the property value is not null, false otherwise
    • isEmpty

      boolean isEmpty()

      Determines whether the value is empty (ie. value is null).

      Returns:
      true if the property value is null, false otherwise
    • as

      <T> Optional<T> as(Class<T> type)

      Converts the property value to the specified type.

      Type Parameters:
      T - the target type
      Parameters:
      type - a class of type T
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • as

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

      Returns the converted value or the specified default value.

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

      <T> Optional<T> as(Type type)

      Converts the property value to the specified type.

      Type Parameters:
      T - the target type
      Parameters:
      type - the target type
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • as

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

      Returns the converted value or the specified default value.

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

      <T> Optional<T[]> asArrayOf(Class<T> type)

      Converts the property value to an array of the specified type.

      Type Parameters:
      T - the target component type
      Parameters:
      type - a class of type T
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asArrayOf

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

      Returns the converted value or the specified default array.

      Type Parameters:
      T - the target component type
      Parameters:
      type - the target component type
      defaultValue - a default array
      Returns:
      the converted value or the default array
    • asArrayOf

      <T> Optional<T[]> asArrayOf(Type type)

      Converts the property value to an array of the specified type.

      Type Parameters:
      T - the target component type
      Parameters:
      type - the target component type
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asArrayOf

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

      Returns the converted value or the specified default array.

      Type Parameters:
      T - the target component type
      Parameters:
      type - the target component type
      defaultValue - a default array
      Returns:
      the converted value or the default array
    • asListOf

      <T> Optional<List<T>> asListOf(Class<T> type)

      Converts the property value to a list of the specified type.

      Type Parameters:
      T - the target list argument type
      Parameters:
      type - a class of type T
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asListOf

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

      Returns the converted value or the specified default list.

      Type Parameters:
      T - the target list argument type
      Parameters:
      type - the target list argument type
      defaultValue - a default list
      Returns:
      the converted value or the default list
    • asListOf

      <T> Optional<List<T>> asListOf(Type type)

      Converts the property value to a list of the specified type.

      Type Parameters:
      T - the target list argument type
      Parameters:
      type - the target list argument type
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asListOf

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

      Returns the converted value or the specified default list.

      Type Parameters:
      T - the target list argument type
      Parameters:
      type - the target list argument type
      defaultValue - a default list
      Returns:
      the converted value or the default list
    • asSetOf

      <T> Optional<Set<T>> asSetOf(Class<T> type)

      Converts the property value to a set of the specified type.

      Type Parameters:
      T - the target set argument type
      Parameters:
      type - a class of type T
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asSetOf

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

      Returns the converted value or the specified default set.

      Type Parameters:
      T - the target set argument type
      Parameters:
      type - the target set argument type
      defaultValue - a default set
      Returns:
      the converted value or the default set
    • asSetOf

      <T> Optional<Set<T>> asSetOf(Type type)

      Converts the property value to a set of the specified type.

      Type Parameters:
      T - the target set argument type
      Parameters:
      type - the target set argument type
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asSetOf

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

      Returns the converted value or the specified default set.

      Type Parameters:
      T - the target set argument type
      Parameters:
      type - the target set argument type
      defaultValue - a default set
      Returns:
      the converted value or the default set
    • asByte

      Optional<Byte> asByte()

      Converts the property value to a byte.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asByte

      byte asByte(byte defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asShort

      Optional<Short> asShort()

      Converts the property value to a short.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asShort

      short asShort(short defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asInteger

      Optional<Integer> asInteger()

      Converts the property value to an integer.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asInteger

      int asInteger(int defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asLong

      Optional<Long> asLong()

      Converts the property value to a long.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asLong

      long asLong(long defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asFloat

      Optional<Float> asFloat()

      Converts the property value to a float.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asFloat

      float asFloat(float defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asDouble

      Optional<Double> asDouble()

      Converts the property value to a double.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asDouble

      double asDouble(double defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asCharacter

      Optional<Character> asCharacter()

      Converts the property value to a character.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asCharacter

      char asCharacter(char defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asString

      Optional<String> asString()

      Converts the property value to a string.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asString

      String asString(String defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asBoolean

      Optional<Boolean> asBoolean()

      Converts the property value to a boolean.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asBoolean

      boolean asBoolean(boolean defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asBigInteger

      Optional<BigInteger> asBigInteger()

      Converts the property value to a big integer.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asBigInteger

      BigInteger asBigInteger(BigInteger defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asBigDecimal

      Optional<BigDecimal> asBigDecimal()

      Converts the property value to a big decimal.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asBigDecimal

      BigDecimal asBigDecimal(BigDecimal defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asLocalDate

      Optional<LocalDate> asLocalDate()

      Converts the property value to a local date.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asLocalDate

      LocalDate asLocalDate(LocalDate defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asLocalDateTime

      Optional<LocalDateTime> asLocalDateTime()

      Converts the property value to a local date time.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asLocalDateTime

      LocalDateTime asLocalDateTime(LocalDateTime defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asZonedDateTime

      Optional<ZonedDateTime> asZonedDateTime()

      Converts the property value to a zoned date time.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asZonedDateTime

      ZonedDateTime asZonedDateTime(ZonedDateTime defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asCurrency

      Optional<Currency> asCurrency()

      Converts the property value to a currency.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asCurrency

      Currency asCurrency(Currency defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asLocale

      Optional<Locale> asLocale()

      Converts the property value to a locale.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asLocale

      Locale asLocale(Locale defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asFile

      Optional<File> asFile()

      Converts the property value to a file.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asFile

      File asFile(File defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asPath

      Optional<Path> asPath()

      Converts the property value to a path.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asPath

      Path asPath(Path defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asURI

      Optional<URI> asURI()

      Converts the property value to a URI.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asURI

      URI asURI(URI defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asURL

      Optional<URL> asURL()

      Converts the property value to a URL.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asURL

      URL asURL(URL defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asPattern

      Optional<Pattern> asPattern()

      Converts the property value to a pattern.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asPattern

      Pattern asPattern(Pattern defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asInetAddress

      Optional<InetAddress> asInetAddress()

      Converts the property value to an inet address.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asInetAddress

      InetAddress asInetAddress(InetAddress defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asInetSocketAddress

      Optional<InetSocketAddress> asInetSocketAddress()

      Converts the property value to an inet socket address.

      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asInetSocketAddress

      InetSocketAddress asInetSocketAddress(InetSocketAddress defaultValue)

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value
    • asClass

      <T> Optional<Class<T>> asClass()

      Converts the property value to a class.

      Type Parameters:
      T - the target type
      Returns:
      an optional returning the converted value or an empty optional if the property is empty
    • asClass

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

      Returns the converted value or the specified default value.

      Parameters:
      defaultValue - a default value
      Returns:
      the converted value or the default value