OptionalDouble
class OptionalDouble
| kotlin.Any | |
| ↳ | java.util.OptionalDouble | 
A container object which may or may not contain a double value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false. 
Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (returns a default value if no value is present) and ifPresent() (performs an action if a value is present). 
This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail.
Summary
| Public methods | |
|---|---|
| static OptionalDouble! | 
            empty()Returns an empty   | 
        
| Boolean | 
            
             Indicates whether some other object is "equal to" this   | 
        
| Double | 
            
             If a value is present, returns the value, otherwise throws   | 
        
| Int | 
            hashCode()Returns the hash code of the value, if present, otherwise   | 
        
| Unit | 
            ifPresent(action: DoubleConsumer!)If a value is present, performs the given action with the value, otherwise does nothing.  | 
        
| Unit | 
            ifPresentOrElse(action: DoubleConsumer!, emptyAction: Runnable!)If a value is present, performs the given action with the value, otherwise performs the given empty-based action.  | 
        
| Boolean | 
            isEmpty()If a value is not present, returns   | 
        
| Boolean | 
            
             If a value is present, returns   | 
        
| static OptionalDouble! | 
            
             Returns an   | 
        
| Double | 
            
             If a value is present, returns the value, otherwise returns   | 
        
| Double | 
            orElseGet(supplier: DoubleSupplier!)If a value is present, returns the value, otherwise returns the result produced by the supplying function.  | 
        
| Double | 
            
             If a value is present, returns the value, otherwise throws   | 
        
| Double | 
            orElseThrow(exceptionSupplier: Supplier<out X>!)If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.  | 
        
| DoubleStream! | 
            stream()If a value is present, returns a sequential   | 
        
| String | 
            toString()Returns a non-empty string representation of this   | 
        
Public methods
empty
static fun empty(): OptionalDouble!
Returns an empty OptionalDouble instance. No value is present for this OptionalDouble.
| Return | |
|---|---|
OptionalDouble! | 
            an empty OptionalDouble. | 
          
equals
fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this OptionalDouble. The other object is considered equal if: 
        
- it is also an 
OptionalDoubleand; - both instances have no value present or;
 - the present values are "equal to" each other via 
Double.compare() == 0. 
| Parameters | |
|---|---|
obj | 
            an object to be tested for equality | 
| Return | |
|---|---|
Boolean | 
            true if the other object is "equal to" this object otherwise false | 
          
getAsDouble
fun getAsDouble(): Double
If a value is present, returns the value, otherwise throws NoSuchElementException.
| Return | |
|---|---|
Double | 
            the value described by this OptionalDouble | 
          
| Exceptions | |
|---|---|
java.util.NoSuchElementException | 
            if no value is present | 
hashCode
fun hashCode(): Int
Returns the hash code of the value, if present, otherwise 0 (zero) if no value is present.
| Return | |
|---|---|
Int | 
            hash code value of the present value or 0 if no value is present | 
          
ifPresent
fun ifPresent(action: DoubleConsumer!): Unit
If a value is present, performs the given action with the value, otherwise does nothing.
| Parameters | |
|---|---|
action | 
            DoubleConsumer!: the action to be performed, if a value is present | 
| Exceptions | |
|---|---|
java.lang.NullPointerException | 
            if value is present and the given action is null | 
          
ifPresentOrElse
fun ifPresentOrElse(
action: DoubleConsumer!,
emptyAction: Runnable!
): Unit
If a value is present, performs the given action with the value, otherwise performs the given empty-based action.
| Parameters | |
|---|---|
action | 
            DoubleConsumer!: the action to be performed, if a value is present | 
emptyAction | 
            Runnable!: the empty-based action to be performed, if no value is present | 
| Exceptions | |
|---|---|
java.lang.NullPointerException | 
            if a value is present and the given action is null, or no value is present and the given empty-based action is null. | 
          
isEmpty
fun isEmpty(): Boolean
If a value is not present, returns true, otherwise false.
| Return | |
|---|---|
Boolean | 
            true if a value is not present, otherwise false | 
          
isPresent
fun isPresent(): Boolean
If a value is present, returns true, otherwise false.
| Return | |
|---|---|
Boolean | 
            true if a value is present, otherwise false | 
          
of
static fun of(value: Double): OptionalDouble!
Returns an OptionalDouble describing the given value.
| Parameters | |
|---|---|
value | 
            Double: the value to describe | 
| Return | |
|---|---|
OptionalDouble! | 
            an OptionalDouble with the value present | 
          
orElse
fun orElse(other: Double): Double
If a value is present, returns the value, otherwise returns other.
| Parameters | |
|---|---|
other | 
            Double: the value to be returned, if no value is present | 
| Return | |
|---|---|
Double | 
            the value, if present, otherwise other | 
          
orElseGet
fun orElseGet(supplier: DoubleSupplier!): Double
If a value is present, returns the value, otherwise returns the result produced by the supplying function.
| Parameters | |
|---|---|
supplier | 
            DoubleSupplier!: the supplying function that produces a value to be returned | 
| Return | |
|---|---|
Double | 
            the value, if present, otherwise the result produced by the supplying function | 
| Exceptions | |
|---|---|
java.lang.NullPointerException | 
            if no value is present and the supplying function is null | 
          
orElseThrow
fun orElseThrow(): Double
If a value is present, returns the value, otherwise throws NoSuchElementException.
| Return | |
|---|---|
Double | 
            the value described by this OptionalDouble | 
          
| Exceptions | |
|---|---|
java.util.NoSuchElementException | 
            if no value is present | 
orElseThrow
fun <X : Throwable!> orElseThrow(exceptionSupplier: Supplier<out X>!): Double
If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.
| Parameters | |
|---|---|
<X> | 
            Type of the exception to be thrown | 
exceptionSupplier | 
            Supplier<out X>!: the supplying function that produces an exception to be thrown | 
| Return | |
|---|---|
Double | 
            the value, if present | 
| Exceptions | |
|---|---|
X | 
            if no value is present | 
java.lang.NullPointerException | 
            if no value is present and the exception supplying function is null | 
          
stream
fun stream(): DoubleStream!
If a value is present, returns a sequential DoubleStream containing only that value, otherwise returns an empty DoubleStream.
| Return | |
|---|---|
DoubleStream! | 
            the optional value as a DoubleStream | 
          
toString
fun toString(): String
Returns a non-empty string representation of this OptionalDouble suitable for debugging. The exact presentation format is unspecified and may vary between implementations and versions.
| Return | |
|---|---|
String | 
            the string representation of this instance |