Top Inners Fields Constructors Methods
org.eclipse.jetty.util

pack-priv Class ServiceLoaderSpliterator<T>

extends Object
implements Spliterator<ServiceLoader.Provider<T>>
Class Inheritance
All Implemented Interfaces
java.util.Spliterator
Imports
java.util.Iterator, .ServiceConfigurationError, .ServiceLoader, .Spliterator, java.util.function.Consumer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ServiceLoaderSpliterator.ServiceProvider<
the service type.
T
>

An implementation of the ServiceLoader.Provider which contains either an instance of the service or an error to be thrown when someone calls get().

Field Summary

Modifier and TypeField and Description
private final Iterator<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
characteristics()

Implements java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements.

public long
estimateSize()

Implements java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

public boolean
tryAdvance(Consumer<? super ServiceLoader.Provider<T>>
The action whose operation is performed at-most once
action
)

Implements java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false.

public Spliterator<ServiceLoader.Provider<T>>
trySplit()

Implements java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iteratorback to summary
private final Iterator<T> iterator

Constructor Detail

ServiceLoaderSpliteratorback to summary
public ServiceLoaderSpliterator(ServiceLoader<T> serviceLoader)

Method Detail

characteristicsback to summary
public int characteristics()

Implements java.util.Spliterator.characteristics.

Doc from java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements. The result is represented as ORed values from ORDERED, DISTINCT, SORTED, SIZED, NONNULL, IMMUTABLE, CONCURRENT, SUBSIZED. Repeated calls to characteristics() on a given spliterator, prior to or in-between calls to trySplit, should always return the same result.

If a Spliterator reports an inconsistent set of characteristics (either those returned from a single invocation or across multiple invocations), no guarantees can be made about any computation using this Spliterator.

Returns:int

a representation of characteristics

Annotations
@Override
estimateSizeback to summary
public long estimateSize()

Implements java.util.Spliterator.estimateSize.

Doc from java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

If this Spliterator is SIZED and has not yet been partially traversed or split, or this Spliterator is SUBSIZED and has not yet been partially traversed, this estimate must be an accurate count of elements that would be encountered by a complete traversal. Otherwise, this estimate may be arbitrarily inaccurate, but must decrease as specified across invocations of trySplit.

Returns:long

the estimated size, or Long.MAX_VALUE if infinite, unknown, or too expensive to compute.

Annotations
@Override
tryAdvanceback to summary
public boolean tryAdvance(Consumer<? super ServiceLoader.Provider<T>> action)

Implements java.util.Spliterator.tryAdvance.

Doc from java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false. If this Spliterator is ORDERED the action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

Parameters
action:Consumer<? super ServiceLoader.Provider<T>>

The action whose operation is performed at-most once

Returns:boolean

false if no remaining elements existed upon entry to this method, else true.

Annotations
@Override
trySplitback to summary
public Spliterator<ServiceLoader.Provider<T>> trySplit()

Implements java.util.Spliterator.trySplit.

Doc from java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

If this Spliterator is ORDERED, the returned Spliterator must cover a strict prefix of the elements.

Unless this Spliterator covers an infinite number of elements, repeated calls to trySplit() must eventually return null. Upon non-null return:

  • the value reported for estimateSize() before splitting, must, after splitting, be greater than or equal to estimateSize() for this and the returned Spliterator; and
  • if this Spliterator is SUBSIZED, then estimateSize() for this spliterator before splitting must be equal to the sum of estimateSize() for this and the returned Spliterator after splitting.

This method may return null for any reason, including emptiness, inability to split after traversal has commenced, data structure constraints, and efficiency considerations.

Returns:Spliterator<ServiceLoader.Provider<T>>

a Spliterator covering some portion of the elements, or null if this spliterator cannot be split

Annotations
@Override
org.eclipse.jetty.util back to summary

private Class ServiceLoaderSpliterator.ServiceProvider<T>

extends Object
implements ServiceLoader.Provider<T>
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.util.ServiceLoaderSpliterator.ServiceProvider
All Implemented Interfaces
java.util.ServiceLoader.Provider, java.util.function.Supplier
Type Parameters
<T>
the service type.

An implementation of the ServiceLoader.Provider which contains either an instance of the service or an error to be thrown when someone calls get().

Field Summary

Modifier and TypeField and Description
private final Throwable
private final T

Constructor Summary

AccessConstructor and Description
public
ServiceProvider(T service)

public

Method Summary

Modifier and TypeMethod and Description
public T
get()

Implements java.util.ServiceLoader.Provider.get.

Returns an instance of the provider.

public Class<? extends T>
type()

Implements java.util.ServiceLoader.Provider.type.

Returns the provider type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorback to summary
private final Throwable error
serviceback to summary
private final T service

Constructor Detail

ServiceProviderback to summary
public ServiceProvider(T service)
ServiceProviderback to summary
public ServiceProvider(Throwable error)

Method Detail

getback to summary
public T get()

Implements java.util.ServiceLoader.Provider.get.

Doc from java.util.ServiceLoader.Provider.get.

Returns an instance of the provider.

Returns:T

An instance of the provider.

Annotations
@Override
typeback to summary
public Class<? extends T> type()

Implements java.util.ServiceLoader.Provider.type.

Doc from java.util.ServiceLoader.Provider.type.

Returns the provider type. There is no guarantee that this type is accessible or that it has a public no-args constructor. The get() method should be used to obtain the provider instance.

When a module declares that the provider class is created by a provider factory then this method returns the return type of its public static "provider()" method.

Returns:Class<? extends T>

The provider type

Annotations
@Override
@SuppressWarnings:unchecked