Interface ConfigurationQueryResult
- All Known Implementing Classes:
CompositeConfigurationSource.CompositeConfigurationQueryResult
,io.inverno.mod.configuration.internal.GenericConfigurationQueryResult
,VersionedRedisConfigurationSource.VersionedRedisConfigurationQueryResult
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 TypeMethodDescription<T> T
Returns the configuration property value converted to the specified type or a default value.<T> T
Returns the configuration property value converted to the specified type or a default value.<T> T[]
Returns the configuration property value converted to an array of the specified type or a default array.<T> T[]
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> 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.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.asInetSocketAddress
(InetSocketAddress defaultValue) 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> Returns the configuration property value converted to a list of the specified type or a default list.<T> List
<T> 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.asLocalDateTime
(LocalDateTime defaultValue) Returns the configuration property value as a local date time or a default value.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.Returns the configuration property value as a path or a default value.Returns the configuration property value as a pattern or a default value.<T> Set
<T> Returns the configuration property value converted to a set of the specified type or a default set.<T> Set
<T> 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.Returns the configuration property value as a string or a default value.Returns the configuration property value as a URI or a default value.Returns the configuration property value as a URL or a default value.asZonedDateTime
(ZonedDateTime defaultValue) 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
ifPresent
(Consumer<? super ConfigurationProperty> action) 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
isEmpty()
Determines whether the result is empty.boolean
Determines whether the result is present.Returns the configuration property if a result is present, otherwise throwsNoSuchElementException
.<X extends Throwable>
ConfigurationPropertyorElseThrow
(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 propertyOptional
.
-
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
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
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 presentemptyAction
- 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 propertyNoSuchElementException
- if the result is empty
-
as
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default value
-
as
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default value
-
asArrayOf
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default array
-
asArrayOf
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default array
-
asListOf
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default list
-
asListOf
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default list
-
asSetOf
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 TdefaultValue
- a default value- Returns:
- the configuration property value or the specified default set
-
asSetOf
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 TdefaultValue
- 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-