Uses of Class
java.util.Optional
Packages that useOptional 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.net.http HTTP Client and WebSocket APIsjava.security.interfaces Provides interfaces for generating RSA (Rivest, Shamir and Adleman AsymmetricCipher algorithm) keys as defined in the RSA Laboratory Technical Note PKCS#1, and DSA (Digital Signature Algorithm) keys as defined in NIST's FIPS-186.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.Uses ofOptional injava.lang
Methods injava.lang that returnOptional 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 thebuild 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, theparent layers.staticOptional<ProcessHandle>ProcessHandle. of(long pid)Returns anOptional<ProcessHandle>for an existing native process.Optional<String>Runtime.Version. optional()Returnsoptional additional identifying build information.Optional<ProcessHandle>ProcessHandle. parent()Returns anOptional<ProcessHandle>for the parent process.Optional<String>Runtime.Version. pre()Returns the optionalpre-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 ofOptional injava.lang.module
Methods injava.lang.module that returnOptional 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, theparent configurations.Optional<URI>ModuleReference. location()Returns the location of this module's content, if known.Optional<String>ModuleDescriptor. mainClass()Returns the module main class.defaultOptional<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 moduledefaultOptional<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 ofOptional injava.net.http
Methods injava.net.http that returnOptional Modifier and Type Method Description abstractOptional<Authenticator>HttpClient. authenticator()Returns anOptionalcontaining theAuthenticatorset on this client.abstractOptional<HttpRequest.BodyPublisher>HttpRequest. bodyPublisher()Returns anOptionalcontaining theHttpRequest.BodyPublisherset on this request.abstractOptional<Duration>HttpClient. connectTimeout()Returns anOptionalcontaining theconnect timeout duration for this client.abstractOptional<CookieHandler>HttpClient. cookieHandler()Returns anOptionalcontaining this client'sCookieHandler.abstractOptional<Executor>HttpClient. executor()Returns anOptionalcontaining this client'sExecutor.Optional<String>HttpHeaders. firstValue(String name)Returns anOptionalcontaining the first header string value of the given named (and possibly multi-valued) header.Optional<HttpResponse<T>>HttpResponse. previousResponse()Returns anOptionalcontaining the previous intermediate response if one was received.abstractOptional<ProxySelector>HttpClient. proxy()Returns anOptionalcontaining theProxySelectorsupplied to this client.Optional<SSLSession>HttpResponse. sslSession()Returns anOptionalcontaining theSSLSessionin effect for this response.abstractOptional<Duration>HttpRequest. timeout()Returns anOptionalcontaining this request's timeout duration.abstractOptional<HttpClient.Version>HttpRequest. version()Returns anOptionalcontaining the HTTP protocol version that will be requested for thisHttpRequest.Method parameters injava.net.http with type arguments of typeOptional Modifier and Type Method Description staticHttpResponse.BodyHandler<Void>HttpResponse.BodyHandlers. ofByteArrayConsumer(Consumer<Optional<byte[]>> consumer)Returns aBodyHandler<Void>that returns aBodySubscriber<Void>obtained fromBodySubscribers.ofByteArrayConsumer(Consumer).staticHttpResponse.BodySubscriber<Void>HttpResponse.BodySubscribers. ofByteArrayConsumer(Consumer<Optional<byte[]>> consumer)Returns aBodySubscriberwhich provides the incoming body data to the provided Consumer ofOptional<byte[]>.Uses ofOptional injava.security.interfaces
Methods injava.security.interfaces that returnOptional Modifier and Type Method Description Optional<byte[]>XECPrivateKey. getScalar()Get the scalar value encoded as an unpruned byte array.Uses ofOptional injava.util
Methods injava.util that returnOptional Modifier and Type Method Description static <T> Optional<T>Optional. empty()Returns an emptyOptionalinstance.Optional<T>Optional. filter(Predicate<? superT> predicate)If a value is present, and the value matches the given predicate, returns anOptionaldescribing 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<? superT,? extendsOptional<? 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<? superT,? extends U> mapper)If a value is present, returns anOptionaldescribing (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 anOptionaldescribing the given non-nullvalue.static <T> Optional<T>Optional. ofNullable(T value)Returns anOptionaldescribing the given value, if non-null, otherwise returns an emptyOptional.Optional<T>Optional. or(Supplier<? extendsOptional<? extendsT>> supplier)If a value is present, returns anOptionaldescribing the value, otherwise returns anOptionalproduced by the supplying function.Method parameters injava.util with type arguments of typeOptional Modifier and Type Method Description <U> Optional<U>Optional. flatMap(Function<? superT,? extendsOptional<? 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<? extendsOptional<? extendsT>> supplier)If a value is present, returns anOptionaldescribing the value, otherwise returns anOptionalproduced by the supplying function.Uses ofOptional injava.util.spi
Methods injava.util.spi that returnOptional Modifier and Type Method Description staticOptional<ToolProvider>ToolProvider. findFirst(String name)Returns the first instance of aToolProviderwith the given name, as loaded byServiceLoaderusing the system class loader.Uses ofOptional injava.util.stream
Methods injava.util.stream that returnOptional Modifier and Type Method Description Optional<T>Stream. findAny()Returns anOptionaldescribing some element of the stream, or an emptyOptionalif the stream is empty.Optional<T>Stream. findFirst()Returns anOptionaldescribing the first element of this stream, or an emptyOptionalif the stream is empty.Optional<T>Stream. max(Comparator<? superT> comparator)Returns the maximum element of this stream according to the providedComparator.Optional<T>Stream. min(Comparator<? superT> comparator)Returns the minimum element of this stream according to the providedComparator.Optional<T>Stream. reduce(BinaryOperator<T> accumulator)Performs areduction on the elements of this stream, using anassociative accumulation function, and returns anOptionaldescribing the reduced value, if any.Methods injava.util.stream that return types with arguments of typeOptional Modifier and Type Method Description static <T> Collector<T,?,Optional<T>>Collectors. maxBy(Comparator<? super T> comparator)Returns aCollectorthat 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 aCollectorthat produces the minimal element according to a givenComparator, described as anOptional<T>.static <T> Collector<T,?,Optional<T>>Collectors. reducing(BinaryOperator<T> op)Returns aCollectorwhich performs a reduction of its input elements under a specifiedBinaryOperator.