lucee.Component testbox.system.modules.cbstreams.models.Optional
A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value. Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (return a default value if value not present) and ifPresent() (execute a block of code if the value is present). See https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html
Property Summary | ||||
---|---|---|---|---|
type | property | default | serializable | required |
any
|
jOptional
The Java Builder we represent.
|
true
|
false
|
Constructor Summary | |
---|---|
init([any optional])
Construct a CFML Optional out of the Java Optional. |
Method Summary | |
---|---|
Optional
|
empty()
Build an empty optional out. |
Optional
|
filter(any predicate)
If a value is present, and the value matches the given predicate, return an Optional describing the value, otherwise return an empty Optional. |
any
|
get()
If a value is present in this Optional, returns the value, otherwise throws NoSuchElementException. |
string
|
getJOptional()
|
any
|
getNativeType([any results])
Return a native CF type from incoming Java type. |
private any
|
getValueFromOptional()
Verify if the optional is of a certain primitive type and call the appropriate function to return it's value. |
numeric
|
hashCode()
Returns the hash code value of the present value, if any, or 0 (zero) if no value is present. |
void
|
ifPresent(any consumer)
If a value is present, invoke the specified consumer with the value, otherwise do nothing. |
boolean
|
isEqual(any obj)
Indicates whether some other object is "equal to" this Optional. |
boolean
|
isPresent()
Return true if there is a value present, otherwise false. |
Optional
|
map(any mapper)
If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. |
Optional
|
of(any value)
Returns an Optional with the specified present non-null value. |
Optional
|
ofNullable([any value])
Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional. |
any
|
orElse(any other)
Return the value if present, otherwise return other. |
any
|
orElseGet(any other)
Return the value if present, otherwise invoke other and return the result of that invocation. |
any
|
setJOptional(any jOptional)
|
string
|
toString()
Returns a non-empty string representation of this Optional suitable for debugging. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Construct a CFML Optional out of the Java Optional. If no optional passed, we will generate an empty one.
optional
- A Java optional to initialize this CFML Optional with.Property Detail |
---|
The Java Builder we represent
access
- publicrequired
- falsereturntype
- anyserializable
- trueMethod Detail |
---|
Build an empty optional out.
If a value is present, and the value matches the given predicate, return an Optional describing the value, otherwise return an empty Optional.
predicate
- a predicate to apply to the value, if presentIf a value is present in this Optional, returns the value, otherwise throws NoSuchElementException.
Return a native CF type from incoming Java type. This is our Java to CF Bridge. Expand as needed
results
- The native Java returnVerify if the optional is of a certain primitive type and call the appropriate function to return it's value. If not, it reverts to a default typedless Optional.
Returns the hash code value of the present value, if any, or 0 (zero) if no value is present.
If a value is present, invoke the specified consumer with the value, otherwise do nothing.
consumer
- block to be executed if a value is presentIndicates whether some other object is "equal to" this Optional. Please note that the incoming must also be an Optional
obj
Return true if there is a value present, otherwise false.
If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional.
mapper
- a mapping function to apply to the value, if presentReturns an Optional with the specified present non-null value.
value
- The value to be present, which must be NON NULLReturns an Optional describing the specified value, if non-null, otherwise returns an empty Optional.
value
- the possibly-null value to describeReturn the value if present, otherwise return other.
other
- the value to be returned if there is no value present, may be nullReturn the value if present, otherwise invoke other and return the result of that invocation.
other
- a Supplier lambda or closure whose result is returned if no value is presentjOptional
Returns a non-empty string representation of this Optional suitable for debugging.