T - The type of the value.public abstract class BaseDynamicValue<T> extends Object implements DynamicValue<T>, Serializable
A accessor for a single configured value. This can be used to support values that may change during runtime,
reconfigured or final. Hereby external code (could be Tamaya configuration listners or client code), can set a
new value. Depending on the UpdatePolicy the new value is immedeately active or it requires an active commit
by client code. Similarly an instance also can ignore all later changes to the value.
Types of this interface can be used as injection targets in injected beans or as template resiult on configuration templates.
| Constructor and Description |
|---|
BaseDynamicValue() |
| Modifier and Type | Method and Description |
|---|---|
T |
commitAndGet()
Performs a commit, if necessary, and returns the current value.
|
boolean |
isPresent()
Return
true if there is a value present, otherwise false. |
T |
orElse(T other)
Return the value if present, otherwise return
other. |
T |
orElseGet(ConfiguredItemSupplier<? extends T> other)
Return the value if present, otherwise invoke
other and return
the result of that invocation. |
<X extends Throwable> |
orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier)
Return the contained value, if present, otherwise throw an exception
to be created by the provided supplier.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, commit, evaluateValue, get, getNewValue, getUpdatePolicy, removeListener, setUpdatePolicy, updateValuepublic T commitAndGet()
commitAndGet in interface DynamicValue<T>DynamicValueorg.apache.tamaya.ConfigException - if there is no value presentDynamicValue.isPresent()public boolean isPresent()
true if there is a value present, otherwise false.isPresent in interface DynamicValue<T>true if there is a value present, otherwise falsepublic T orElse(T other)
other.orElse in interface DynamicValue<T>other - the value to be returned if there is no value present, may
be nullotherpublic T orElseGet(ConfiguredItemSupplier<? extends T> other)
other and return
the result of that invocation.orElseGet in interface DynamicValue<T>other - a ConfiguredItemSupplier whose result is returned if no value
is presentother.get()NullPointerException - if value is not present and other is
nullpublic <X extends Throwable> T orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X extends Throwable
NOTE A method reference to the exception constructor with an empty
argument list can be used as the supplier. For example,
IllegalStateException::new
orElseThrow in interface DynamicValue<T>X - Type of the exception to be thrownexceptionSupplier - The supplier which will return the exception to
be thrownX - if there is no value presentNullPointerException - if no value is present and
exceptionSupplier is nullX extends ThrowableCopyright © 2014–2016 Apache Software Foundation. All rights reserved.