- Type Parameters:
T- the type of configured objects thisDefaultLoadersupplies
- All Implemented Interfaces:
AutoCloseable,Supplier<T>,OptionalSupplier<T>,Loader<T>
Loader implementation that delegates
its work to Providers and an AmbiguityHandler.- Author:
- Laird Nelson
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.microbean.invoke.OptionalSupplier
OptionalSupplier.Determinism -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newDefaultLoader.DefaultLoader(Collection<? extends Provider> providers) Creates a newDefaultLoaderthat will use the suppliedProviders and anAmbiguityHandlerdisovered via theServiceLoadermechanism.DefaultLoader(Collection<? extends Provider> providers, AmbiguityHandler ambiguityHandler) -
Method Summary
Modifier and TypeMethodDescriptionfinal AmbiguityHandlerReturns theAmbiguityHandlerassociated with thisDefaultLoader.final voidclose()Clears any caches used by thisDefaultLoader.Returns aOptionalSupplier.Determinismsuitable for thisDefaultLoader.final Tget()final <U> DefaultLoader<U>Returns aDefaultLoaderthat can supply environmental objects that are suitable for the suppliedpath.final Loader<?>parent()Returns theLoaderserving as the parent of thisDefaultLoader.path()Returns thePathwith which thisDefaultLoaderwas created.final DefaultLoader<T>plus(Collection<? extends Provider> providers) final DefaultLoader<T>final Collection<Provider>final DefaultLoader<T>with(Collection<? extends Provider> providers) final DefaultLoader<T>with(AmbiguityHandler ambiguityHandler) Returns aDefaultLoaderthat uses the suppliedAmbiguityHandler.final DefaultLoader<T>Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.microbean.loader.api.Loader
absolutePath, as, isRoot, load, load, load, load, load, load, load, load, load, load, load, load, load, load, load, loaderFor, root, transliterateMethods inherited from interface org.microbean.invoke.OptionalSupplier
exceptionally, handle, ifPresent, ifPresentOrElse, optional, optional, optional, orElse, orElseGet, orElseThrow, orElseThrow, stream
-
Constructor Details
-
DefaultLoader
public DefaultLoader()Creates a newDefaultLoader.The new
DefaultLoaderwill returnthisfrom itsparent()method.- See Also:
-
DefaultLoader
Creates a newDefaultLoaderthat will use the suppliedProviders and anAmbiguityHandlerdisovered via theServiceLoadermechanism.The new
DefaultLoaderwill returnthisfrom itsparent()method.- Parameters:
providers- theProviders to use; may benullin which caseProviders will be discovered using theServiceLoadermechanism; may be empty in which case the newDefaultLoadermay be useless
-
DefaultLoader
Creates a newDefaultLoaderthat will use the suppliedProviders andAmbiguityHandler.The new
DefaultLoaderwill returnthisfrom itsparent()method.- Parameters:
providers- theProviders to use; may benullin which caseProviders will be discovered using theServiceLoadermechanism; may be empty in which case the newDefaultLoadermay be uselessambiguityHandler- theAmbiguityHandlerto use; may benullin which case anAmbiguityHandlerwill be discovered using theServiceLoadermechanism
-
-
Method Details
-
close
Clears any caches used by thisDefaultLoader.This
DefaultLoaderremains valid to use.- Specified by:
closein interfaceAutoCloseable- Idempotency:
- This method is deterministic but not idempotent unless the caches are already cleared.
- Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
plus
- Parameters:
provider- the additionalProvider; may benullin which casethiswill be returned- Returns:
- a
DefaultLoaderthat uses the additionalProvider - Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoaderto return) but is deterministic. - Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
plus
- Parameters:
providers- the additionalProviders; may benullor empty in which casethiswill be returned- Returns:
- a
DefaultLoaderthat uses the additionalProviders - Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoaderto return) but is deterministic. - Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
with
- Parameters:
provider- theProvider; may benullin which caseProviders will be loaded using theServiceLoaderclass- Returns:
- a
DefaultLoaderthat uses only the suppliedProvider - Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoaderto return) but is deterministic. - Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
with
- Parameters:
providers- theProviders; may benullor empty in which caseProviders will be loaded using theServiceLoaderclass- Returns:
- a
DefaultLoaderthat uses only the suppliedProviders - Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoaderto return) but is deterministic. - Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
with
Returns aDefaultLoaderthat uses the suppliedAmbiguityHandler.- Parameters:
ambiguityHandler- theAmbiguityHandler; must not benull- Returns:
- a
DefaultLoaderthat uses the suppliedAmbiguityHandler - Throws:
NullPointerException- ifambiguityHandlerisnull- Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoaderto return) but is deterministic. - Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
providers
Returns an unmodifiableCollectionofProviders that thisDefaultLoaderwill use to supply objects.This method never returns
null.- Returns:
- an unmodifiable
CollectionofProviders that thisDefaultLoaderwill use to supply objects; nevernull - Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
ambiguityHandler
- Returns:
- the
AmbiguityHandlerassociated with thisDefaultLoader; nevernull - See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
parent
Returns theLoaderserving as the parent of thisDefaultLoader.The "root"
DefaultLoaderreturns itself from itsparent()implementation.This method never returns
null.- Specified by:
parentin interfaceLoader<T>- Returns:
- the non-
nullLoaderserving as the parent of thisDefaultLoader; may be thisDefaultLoaderitself - See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
path
Returns thePathwith which thisDefaultLoaderwas created.The
Paththat is returned by this method is not guaranteed to be absolute.The
Paththat is returned by this method will be equal to a transliterated version of thePaththat was supplied to theload(Path)method of thisDefaultLoader's parent that resulted in thisDefaultLoader's creation.- Specified by:
pathin interfaceLoader<T>- Returns:
- the non-
nullPathwith which thisDefaultLoaderwas created - See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null., Implementations of this method must not returnnull. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
absolutePath
Returns the absolutePathrepresenting thePathwith which thisDefaultLoaderwas created.The
Paththat is returned by this method is guaranteed to be absolute.The
Paththat is returned by this method will be equal to a transliterated and absolute version of thePaththat was supplied to theload(Path)method of thisDefaultLoader's parent that resulted in thisDefaultLoader's creation.- Specified by:
absolutePathin interfaceLoader<T>- Returns:
- the non-
nullabsolutePathrepresenting thePathwith which thisDefaultLoaderwas created - See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null., Implementations of this method must not returnnull. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
determinism
Returns aOptionalSupplier.Determinismsuitable for thisDefaultLoader.- Specified by:
determinismin interfaceOptionalSupplier<T>- Returns:
- a
OptionalSupplier.Determinismsuitable for thisDefaultLoader - Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
get
-
load
Returns aDefaultLoaderthat can supply environmental objects that are suitable for the suppliedpath.This method never returns
null.The
DefaultLoaderthat is returned may returnnullfrom itsget()method. Additionally, theDefaultLoaderthat is returned may throwNoSuchElementExceptionorUnsupportedOperationExceptionfrom itsget()method.- Specified by:
loadin interfaceLoader<T>- Type Parameters:
U- the type of the suppliedPathand the type of the returnedDefaultLoader- Parameters:
path- thePathfor which aDefaultLoadershould be returned; must not benull- Returns:
- a
DefaultLoadercapable of supplying environmental objects suitable for the suppliedpath; nevernull - Throws:
NullPointerException- ifpathisnullIllegalArgumentException- if thepath, after normalization, is the rootPath- See Also:
- Nullability:
- This method never returns
null. - Thread Safety:
- This method is safe for concurrent use by multiple threads., This method is idempotent and deterministic.
-