Package org.jvnet.hk2.internal
Class IterableProviderImpl<T>
- java.lang.Object
-
- org.jvnet.hk2.internal.IterableProviderImpl<T>
-
- Type Parameters:
T
- The type for this provider
- All Implemented Interfaces:
java.lang.Iterable<T>
,javax.inject.Provider<T>
,IterableProvider<T>
public class IterableProviderImpl<T> extends java.lang.Object implements IterableProvider<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
IterableProviderImpl.HandleIterable<U>
private static class
IterableProviderImpl.MyHandleIterator<U>
private static class
IterableProviderImpl.MyIterator<U>
-
Field Summary
Fields Modifier and Type Field Description private boolean
isIterable
private ServiceLocatorImpl
locator
private Injectee
originalInjectee
private java.util.Set<java.lang.annotation.Annotation>
requiredQualifiers
private java.lang.reflect.Type
requiredType
private Unqualified
unqualified
-
Constructor Summary
Constructors Constructor Description IterableProviderImpl(ServiceLocatorImpl locator, java.lang.reflect.Type requiredType, java.util.Set<java.lang.annotation.Annotation> requiredQualifiers, Unqualified unqualified, Injectee originalInjectee, boolean isIterable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
ServiceHandle<T>
getHandle()
Rather than getting the service directly with get (in which case the returned service cannot be disposed of) this method will instead return a service handle for the current best service.int
getSize()
Returns the size of the iterator that would be returnedjava.lang.Iterable<ServiceHandle<T>>
handleIterator()
This version of iterator returns an iterator of ServiceHandles rather than returning the services (which then have no way to be properly destroyed)java.util.Iterator<T>
iterator()
private void
justInTime()
IterableProvider<T>
named(java.lang.String name)
Returns an IterableProvider that is further qualified with the given name<U> IterableProvider<U>
ofType(java.lang.reflect.Type type)
Returns an IterableProvider that is of the given type.IterableProvider<T>
qualifiedWith(java.lang.annotation.Annotation... qualifiers)
A set of qualifiers to further restrict this iterator to.java.lang.String
toString()
-
-
-
Field Detail
-
locator
private final ServiceLocatorImpl locator
-
requiredType
private final java.lang.reflect.Type requiredType
-
requiredQualifiers
private final java.util.Set<java.lang.annotation.Annotation> requiredQualifiers
-
unqualified
private final Unqualified unqualified
-
originalInjectee
private final Injectee originalInjectee
-
isIterable
private final boolean isIterable
-
-
Constructor Detail
-
IterableProviderImpl
IterableProviderImpl(ServiceLocatorImpl locator, java.lang.reflect.Type requiredType, java.util.Set<java.lang.annotation.Annotation> requiredQualifiers, Unqualified unqualified, Injectee originalInjectee, boolean isIterable)
-
-
Method Detail
-
justInTime
private void justInTime()
-
getHandle
public ServiceHandle<T> getHandle()
Description copied from interface:IterableProvider
Rather than getting the service directly with get (in which case the returned service cannot be disposed of) this method will instead return a service handle for the current best service.- Specified by:
getHandle
in interfaceIterableProvider<T>
- Returns:
- A ServiceHandle for the service, or null if there is currently no service definition available
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
getSize
public int getSize()
Description copied from interface:IterableProvider
Returns the size of the iterator that would be returned- Specified by:
getSize
in interfaceIterableProvider<T>
- Returns:
- the size of the iterator that would be chosen
-
named
public IterableProvider<T> named(java.lang.String name)
Description copied from interface:IterableProvider
Returns an IterableProvider that is further qualified with the given name- Specified by:
named
in interfaceIterableProvider<T>
- Parameters:
name
- The value field of the Named annotation parameter. Must not be null- Returns:
- An iterable provider further qualified with the given name
-
ofType
public <U> IterableProvider<U> ofType(java.lang.reflect.Type type)
Description copied from interface:IterableProvider
Returns an IterableProvider that is of the given type. This type must be one of the type safe contracts of the original iterator- Specified by:
ofType
in interfaceIterableProvider<T>
- Parameters:
type
- The type to restrict the returned iterator to- Returns:
- An iterator restricted to only providing the given type
-
qualifiedWith
public IterableProvider<T> qualifiedWith(java.lang.annotation.Annotation... qualifiers)
Description copied from interface:IterableProvider
A set of qualifiers to further restrict this iterator to.- Specified by:
qualifiedWith
in interfaceIterableProvider<T>
- Parameters:
qualifiers
- The qualifiers to further restrict this iterator to- Returns:
- An iterator restricted with the given qualifiers
-
handleIterator
public java.lang.Iterable<ServiceHandle<T>> handleIterator()
Description copied from interface:IterableProvider
This version of iterator returns an iterator of ServiceHandles rather than returning the services (which then have no way to be properly destroyed)- Specified by:
handleIterator
in interfaceIterableProvider<T>
- Returns:
- An iterator of ServiceHandles for the set of services represtended by this IterableProvider
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-