Class Setting<T>
- Type Parameters:
T- The type of value supplied.
- All Implemented Interfaces:
Supplier<T>,OptionalSupplier<T>
- Direct Known Subclasses:
StringSetting
This class extends ResettableSupplier to provide methods to convert the string value
to various types, similar to the StringSetting.asInteger(), StringSetting.asBoolean(), etc. methods.
Example:
StringSetting
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying Optional<T>.If a value is present, and the value matches the given predicate, returns a Setting describing the value, otherwise returns an empty Setting.Returns the Settings instance that created this setting.<U> Setting<U>If a value is present, applies the provided mapping function to it and returns a Setting describing the result.Methods inherited from class org.apache.juneau.commons.function.ResettableSupplier
copy, get, isSupplied, reset, setMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.juneau.commons.function.OptionalSupplier
flatMap, ifPresent, ifPresentOrElse, isEmpty, isPresent, orElse, orElseGet, orElseThrow, toOptional
-
Constructor Details
-
Setting
Creates a new Setting from a Settings instance and a Supplier.- Parameters:
settings- The Settings instance that created this setting. Must not benull .supplier- The supplier that provides the value. Must not benull .
-
-
Method Details
-
getSettings
Returns the Settings instance that created this setting.- Returns:
- The Settings instance.
-
asOptional
Returns the underlying Optional<T>.Note: The returned
Optionalis a snapshot-in-time of the current value. Resetting thisSettingwill not affect the returnedOptionalinstance. To get an updated value after resetting, call this method again.- Returns:
- The optional value.
-
map
If a value is present, applies the provided mapping function to it and returns a Setting describing the result.The returned Setting maintains its own cache, independent of this supplier. Resetting the mapped supplier does not affect this supplier, and vice versa.
- Specified by:
mapin interfaceOptionalSupplier<T>- Overrides:
mapin classResettableSupplier<T>- Type Parameters:
U- The type of the result of the mapping function.- Parameters:
mapper- A mapping function to apply to the value, if present. Must not benull .- Returns:
- A Setting describing the result of applying a mapping function to the value of this Setting, if a value is present, otherwise an empty Setting.
-
filter
If a value is present, and the value matches the given predicate, returns a Setting describing the value, otherwise returns an empty Setting.The returned Setting maintains its own cache, independent of this supplier. Resetting the filtered supplier does not affect this supplier, and vice versa.
- Specified by:
filterin interfaceOptionalSupplier<T>- Overrides:
filterin classResettableSupplier<T>- Parameters:
predicate- A predicate to apply to the value, if present. Must not benull .- Returns:
- A Setting describing the value of this Setting if a value is present and the value matches the given predicate, otherwise an empty Setting.
-