Uses of Class
java.util.Optional
-
Packages that use Optional Package Description java.lang Provides classes that are fundamental to the design of the Java programming language.java.lang.module Classes to support module descriptors and creating configurations of modules by means of resolution and service binding.java.util Contains the collections framework, some internationalization support classes, a service loader, properties, random number generation, string parsing and scanning classes, base64 encoding and decoding, a bit array, and several miscellaneous utility classes.java.util.spi Service provider classes for the classes in the java.util package.java.util.stream Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.javafx.scene.control The JavaFX User Interface Controls (UI Controls or just Controls) are specialized Nodes in the JavaFX Scenegraph especially suited for reuse in many different application contexts.jdk.incubator.http High level HTTP and WebSocket API -
-
Uses of Optional in java.lang
Methods in java.lang that return Optional Modifier and Type Method Description Optional<String[]>
ProcessHandle.Info. arguments()
Returns an array of Strings of the arguments of the process.Optional<Integer>
Runtime.Version. build()
Returns the build number.Optional<String>
ProcessHandle.Info. command()
Returns the executable pathname of the process.Optional<String>
ProcessHandle.Info. commandLine()
Returns the command line of the process.Optional<Module>
ModuleLayer. findModule(String name)
Returns the module with the given name in this layer, or if not in this layer, the parent layers.static Optional<ProcessHandle>
ProcessHandle. of(long pid)
Returns anOptional<ProcessHandle>
for an existing native process.Optional<String>
Runtime.Version. optional()
Returns optional additional identifying build information.Optional<ProcessHandle>
ProcessHandle. parent()
Returns anOptional<ProcessHandle>
for the parent process.Optional<String>
Runtime.Version. pre()
Returns the optional pre-release information.Optional<Instant>
ProcessHandle.Info. startInstant()
Returns the start time of the process.Optional<Duration>
ProcessHandle.Info. totalCpuDuration()
Returns the total cputime accumulated of the process.Optional<String>
ProcessHandle.Info. user()
Return the user of the process. -
Uses of Optional in java.lang.module
Methods in java.lang.module that return Optional Modifier and Type Method Description Optional<ModuleDescriptor.Version>
ModuleDescriptor.Requires. compiledVersion()
Returns the version of the module if recorded at compile-time.Optional<ModuleReference>
ModuleFinder. find(String name)
Finds a reference to a module of a given name.Optional<URI>
ModuleReader. find(String name)
Finds a resource, returning a URI to the resource in the module.Optional<ResolvedModule>
Configuration. findModule(String name)
Finds a resolved module in this configuration, or if not in this configuration, the parent configurations.Optional<URI>
ModuleReference. location()
Returns the location of this module's content, if known.Optional<String>
ModuleDescriptor. mainClass()
Returns the module main class.default Optional<InputStream>
ModuleReader. open(String name)
Opens a resource, returning an input stream to read the resource in the module.Optional<String>
ModuleDescriptor.Requires. rawCompiledVersion()
Returns the string with the possibly-unparseable version of the module if recorded at compile-time.Optional<String>
ModuleDescriptor. rawVersion()
Returns the string with the possibly-unparseable version of the moduledefault Optional<ByteBuffer>
ModuleReader. read(String name)
Reads a resource, returning a byte buffer with the contents of the resource.Optional<ModuleDescriptor.Version>
ModuleDescriptor. version()
Returns the module version. -
Uses of Optional in java.util
Methods in java.util that return Optional Modifier and Type Method Description static <T> Optional<T>
Optional. empty()
Returns an emptyOptional
instance.Optional<T>
Optional. filter(Predicate<? super T> predicate)
If a value is present, and the value matches the given predicate, returns anOptional
describing the value, otherwise returns an emptyOptional
.Optional<S>
ServiceLoader. findFirst()
Load the first available service provider of this loader's service.<U> Optional<U>
Optional. flatMap(Function<? super T,? extends Optional<? extends U>> mapper)
If a value is present, returns the result of applying the givenOptional
-bearing mapping function to the value, otherwise returns an emptyOptional
.<U> Optional<U>
Optional. map(Function<? super T,? extends U> mapper)
If a value is present, returns anOptional
describing (as if byofNullable(T)
) the result of applying the given mapping function to the value, otherwise returns an emptyOptional
.static <T> Optional<T>
Optional. of(T value)
Returns anOptional
describing the given non-null
value.static <T> Optional<T>
Optional. ofNullable(T value)
Returns anOptional
describing the given value, if non-null
, otherwise returns an emptyOptional
.Optional<T>
Optional. or(Supplier<? extends Optional<? extends T>> supplier)
If a value is present, returns anOptional
describing the value, otherwise returns anOptional
produced by the supplying function.Method parameters in java.util with type arguments of type Optional Modifier and Type Method Description <U> Optional<U>
Optional. flatMap(Function<? super T,? extends Optional<? extends U>> mapper)
If a value is present, returns the result of applying the givenOptional
-bearing mapping function to the value, otherwise returns an emptyOptional
.Optional<T>
Optional. or(Supplier<? extends Optional<? extends T>> supplier)
If a value is present, returns anOptional
describing the value, otherwise returns anOptional
produced by the supplying function. -
Uses of Optional in java.util.spi
Methods in java.util.spi that return Optional Modifier and Type Method Description static Optional<ToolProvider>
ToolProvider. findFirst(String name)
Returns the first instance of aToolProvider
with the given name, as loaded byServiceLoader
using the system class loader. -
Uses of Optional in java.util.stream
Methods in java.util.stream that return Optional Modifier and Type Method Description Optional<T>
Stream. findAny()
Returns anOptional
describing some element of the stream, or an emptyOptional
if the stream is empty.Optional<T>
Stream. findFirst()
Returns anOptional
describing the first element of this stream, or an emptyOptional
if the stream is empty.Optional<T>
Stream. max(Comparator<? super T> comparator)
Returns the maximum element of this stream according to the providedComparator
.Optional<T>
Stream. min(Comparator<? super T> comparator)
Returns the minimum element of this stream according to the providedComparator
.Optional<T>
Stream. reduce(BinaryOperator<T> accumulator)
Performs a reduction on the elements of this stream, using an associative accumulation function, and returns anOptional
describing the reduced value, if any.Methods in java.util.stream that return types with arguments of type Optional Modifier and Type Method Description static <T> Collector<T,?,Optional<T>>
Collectors. maxBy(Comparator<? super T> comparator)
Returns aCollector
that produces the maximal element according to a givenComparator
, described as anOptional<T>
.static <T> Collector<T,?,Optional<T>>
Collectors. minBy(Comparator<? super T> comparator)
Returns aCollector
that produces the minimal element according to a givenComparator
, described as anOptional<T>
.static <T> Collector<T,?,Optional<T>>
Collectors. reducing(BinaryOperator<T> op)
Returns aCollector
which performs a reduction of its input elements under a specifiedBinaryOperator
. -
Uses of Optional in javafx.scene.control
Methods in javafx.scene.control that return Optional Modifier and Type Method Description Optional<R>
Dialog. showAndWait()
Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input). -
Uses of Optional in jdk.incubator.http
Methods in jdk.incubator.http that return Optional Modifier and Type Method Description abstract Optional<Authenticator>
HttpClient. authenticator()
Returns anOptional
containing theAuthenticator
set on this client.abstract Optional<HttpRequest.BodyProcessor>
HttpRequest. bodyProcessor()
Returns anOptional
containing theHttpRequest.BodyProcessor
set on this request.abstract Optional<CookieManager>
HttpClient. cookieManager()
Returns anOptional
which contains this client'sCookieManager
.Optional<String>
HttpHeaders. firstValue(String name)
Returns anOptional
containing the first value of the given named (and possibly multi-valued) header.Optional<HttpResponse.BodyHandler<T>>
HttpResponse.MultiProcessor. onRequest(HttpRequest request)
Called for the main request and each push promise that is received.abstract Optional<ProxySelector>
HttpClient. proxy()
Returns anOptional
containing theProxySelector
for this client.abstract Optional<SSLParameters>
HttpClient. sslParameters()
Returns anOptional
containing theSSLParameters
set on this client.abstract Optional<HttpClient.Version>
HttpRequest. version()
Returns anOptional
containing the HTTP protocol version that will be requested for thisHttpRequest
.Method parameters in jdk.incubator.http with type arguments of type Optional Modifier and Type Method Description static HttpResponse.BodyHandler<Void>
HttpResponse.BodyHandler. asByteArrayConsumer(Consumer<Optional<byte[]>> consumer)
Returns aBodyHandler<Void>
that returns aBodyProcessor
<Void>
obtained fromBodyProcessor.asByteArrayConsumer(Consumer)
.static HttpResponse.BodyProcessor<Void>
HttpResponse.BodyProcessor. asByteArrayConsumer(Consumer<Optional<byte[]>> consumer)
Returns aBodyProcessor
which provides the incoming body data to the provided Consumer ofOptional<byte[]>
.static <V> HttpResponse.MultiProcessor<MultiMapResult<V>,V>
HttpResponse.MultiProcessor. asMap(Function<HttpRequest,Optional<HttpResponse.BodyHandler<V>>> pushHandler)
Returns a general purpose handler for multi responses.static <V> HttpResponse.MultiProcessor<MultiMapResult<V>,V>
HttpResponse.MultiProcessor. asMap(Function<HttpRequest,Optional<HttpResponse.BodyHandler<V>>> pushHandler, boolean completion)
Returns a general purpose handler for multi responses.
-