Uses of Class
java.util.Optional
Packages that useOptional
Package
Description
Provides classes that are fundamental to the design of the Java programming language.
Classes and interfaces to representnominal descriptors for run-time entities such as classes or method handles, and classfile entities such as constant pool entries or
invokedynamic call sites.The
java.lang.invoke package provides low-level primitives for interacting with the Java Virtual Machine.Classes to support module descriptors and creating configurations of modules by means of resolution and service binding.
Provides the classes for implementing networking applications.
HTTP Client and WebSocket APIs
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.
Provides classes and interfaces for key specifications and algorithm parameter specifications.
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.
Service provider classes for the classes in the java.util package.
Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.
Provides classes for the secure socket package.
Classes to support low-level and efficient foreign memory/function access, directly from Java.
Uses ofOptional injava.lang
Modifier and TypeMethodDescriptionProcessHandle.Info.arguments()Returns an array of Strings of the arguments of the process.Runtime.Version.build()Returns thebuild number.ProcessHandle.Info.command()Returns the executable pathname of the process.ProcessHandle.Info.commandLine()Returns the command line of the process.Boolean.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance.Byte.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance.Character.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance.Class.describeConstable()Returns a nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be.Double.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance, which is the instance itself.finalOptional<Enum.EnumDesc<E>>Enum.describeConstable()Returns an enum descriptorEnumDescfor this instance, if one can be constructed, or an emptyOptionalif one cannot be.Float.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance, which is the instance itself.Integer.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance, which is the instance itself.Long.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance, which is the instance itself.Short.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance.String.describeConstable()Returns anOptionalcontaining the nominal descriptor for this instance, which is the instance itself.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.Runtime.Version.optional()Returnsoptional additional identifying build information.ProcessHandle.parent()Returns anOptional<ProcessHandle>for the parent process.Runtime.Version.pre()Returns the optionalpre-release information.ProcessHandle.Info.startInstant()Returns the start time of the process.ProcessHandle.Info.totalCpuDuration()Returns the total cputime accumulated of the process.ProcessHandle.Info.user()Return the user of the process.Uses ofOptional injava.lang.constant
Methods injava.lang.constant that returnOptionalUses ofOptional injava.lang.invoke
Methods injava.lang.invoke that returnOptionalModifier and TypeMethodDescriptionMethodHandle.describeConstable()Return a nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be.MethodType.describeConstable()Returns a nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be.VarHandle.describeConstable()Return a nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be.Uses ofOptional injava.lang.module
Methods injava.lang.module that returnOptionalModifier and TypeMethodDescriptionModuleDescriptor.Requires.compiledVersion()Returns the version of the module if recorded at compile-time.Finds a reference to a module of a given name.Finds a resource, returning a URI to the resource in the module.Configuration.findModule(String name) Finds a resolved module in this configuration, or if not in this configuration, theparent configurations.ModuleReference.location()Returns the location of this module's content, if known.ModuleDescriptor.mainClass()Returns the module main class.defaultOptional<InputStream>Opens a resource, returning an input stream to read the resource in the module.ModuleDescriptor.Requires.rawCompiledVersion()Returns the string with the possibly-unparseable version of the module if recorded at compile-time.ModuleDescriptor.rawVersion()Returns the string with the possibly-unparseable version of the module.defaultOptional<ByteBuffer>Reads a resource, returning a byte buffer with the contents of the resource.ModuleDescriptor.version()Returns the module version.Uses ofOptional injava.net
Modifier and TypeMethodDescriptionSecureCacheResponse.getSSLSession()Returns anOptionalcontaining theSSLSessionin use on the original connection that retrieved the network resource.Uses ofOptional injava.net.http
Methods injava.net.http that returnOptionalModifier and TypeMethodDescriptionabstractOptional<Authenticator>HttpClient.authenticator()Returns anOptionalcontaining theAuthenticatorset on this client.abstractOptional<HttpRequest.BodyPublisher>HttpRequest.bodyPublisher()Returns anOptionalcontaining theHttpRequest.BodyPublisherset on this request.HttpClient.connectTimeout()Returns anOptionalcontaining theconnect timeout duration for this client.abstractOptional<CookieHandler>HttpClient.cookieHandler()Returns anOptionalcontaining this client'sCookieHandler.HttpClient.executor()Returns anOptionalcontaining this client'sExecutor.HttpHeaders.firstValue(String name) Returns anOptionalcontaining the first header string value of the given named (and possibly multi-valued) header.HttpResponse.previousResponse()Returns anOptionalcontaining the previous intermediate response if one was received.abstractOptional<ProxySelector>HttpClient.proxy()Returns anOptionalcontaining theProxySelectorsupplied to this client.HttpResponse.sslSession()Returns anOptionalcontaining theSSLSessionin effect for this response.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 typeOptionalModifier and TypeMethodDescriptionstaticHttpResponse.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 returnOptionalUses ofOptional injava.security.spec
Methods injava.security.spec that returnOptionalModifier and TypeMethodDescriptionOptional<byte[]>EdDSAParameterSpec.getContext()Get the context that the signature will use.Uses ofOptional injava.util
Modifier and TypeMethodDescriptionstatic <T> Optional<T>Optional.empty()Returns an emptyOptionalinstance.If a value is present, and the value matches the given predicate, returns anOptionaldescribing the value, otherwise returns an emptyOptional.ServiceLoader.findFirst()Load the first available service provider of this loader's service.<U> Optional<U>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>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.If a value is present, returns anOptionaldescribing the value, otherwise returns anOptionalproduced by the supplying function.Modifier and TypeMethodDescription<U> Optional<U>If a value is present, returns the result of applying the givenOptional-bearing mapping function to the value, otherwise returns an emptyOptional.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 returnOptionalModifier and TypeMethodDescriptionstaticOptional<ToolProvider>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 returnOptionalModifier and TypeMethodDescriptionStream.findAny()Returns anOptionaldescribing some element of the stream, or an emptyOptionalif the stream is empty.Stream.findFirst()Returns anOptionaldescribing the first element of this stream, or an emptyOptionalif the stream is empty.Stream.max(Comparator<? superT> comparator) Returns the maximum element of this stream according to the providedComparator.Stream.min(Comparator<? superT> comparator) Returns the minimum element of this stream according to the providedComparator.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 typeOptionalModifier and TypeMethodDescriptionCollectors.maxBy(Comparator<? super T> comparator) Returns aCollectorthat produces the maximal element according to a givenComparator, described as anOptional<T>.Collectors.minBy(Comparator<? super T> comparator) Returns aCollectorthat produces the minimal element according to a givenComparator, described as anOptional<T>.Collectors.reducing(BinaryOperator<T> op) Returns aCollectorwhich performs a reduction of its input elements under a specifiedBinaryOperator.Uses ofOptional injavax.naming.ldap.spi
Methods injavax.naming.ldap.spi that returnOptionalModifier and TypeMethodDescriptionabstractOptional<LdapDnsProviderResult>LdapDnsProvider.lookupEndpoints(String url,Map<?, ?> env) Lookup the endpoints and domain name for the givenContextprovider URLand environment.Uses ofOptional injavax.net.ssl
Methods injavax.net.ssl that returnOptionalModifier and TypeMethodDescriptionHttpsURLConnection.getSSLSession()Returns anOptionalcontaining theSSLSessionin use on this connection.Uses ofOptional injdk.incubator.foreign
Methods injdk.incubator.foreign that returnOptionalModifier and TypeMethodDescriptionReturns the attribute with the given name (if it exists).Returns the attribute with the given name (if it exists).FunctionDescriptor.describeConstable()GroupLayout.describeConstable()Optional<? extendsDynamicConstantDesc<? extendsMemoryLayout>>MemoryLayout.describeConstable()SequenceLayout.describeConstable()ValueLayout.describeConstable()Looks up a symbol with given name in this lookup.MemoryLayout.name()Return thename (if any) associated with this layout.FunctionDescriptor.returnLayout()Returns the return layout associated with this function.