- Type Parameters:
T
- the type of configured objects thisDefaultLoader
supplies
- All Implemented Interfaces:
AutoCloseable
,Supplier<T>
,OptionalSupplier<T>
,Loader<T>
Loader
implementation that delegates
its work to Provider
s 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
ConstructorDescriptionCreates a newDefaultLoader
.DefaultLoader
(Collection<? extends Provider> providers) Creates a newDefaultLoader
that will use the suppliedProvider
s and anAmbiguityHandler
disovered via theServiceLoader
mechanism.DefaultLoader
(Collection<? extends Provider> providers, AmbiguityHandler ambiguityHandler) -
Method Summary
Modifier and TypeMethodDescriptionfinal AmbiguityHandler
Returns theAmbiguityHandler
associated with thisDefaultLoader
.final void
close()
Clears any caches used by thisDefaultLoader
.Returns aOptionalSupplier.Determinism
suitable for thisDefaultLoader
.final T
get()
final <U> DefaultLoader<U>
Returns aDefaultLoader
that can supply environmental objects that are suitable for the suppliedpath
.final Loader<?>
parent()
Returns theLoader
serving as the parent of thisDefaultLoader
.path()
Returns thePath
with which thisDefaultLoader
was 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 aDefaultLoader
that uses the suppliedAmbiguityHandler
.final DefaultLoader<T>
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, transliterate
Methods 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
DefaultLoader
will returnthis
from itsparent()
method.- See Also:
-
DefaultLoader
Creates a newDefaultLoader
that will use the suppliedProvider
s and anAmbiguityHandler
disovered via theServiceLoader
mechanism.The new
DefaultLoader
will returnthis
from itsparent()
method.- Parameters:
providers
- theProvider
s to use; may benull
in which caseProvider
s will be discovered using theServiceLoader
mechanism; may be empty in which case the newDefaultLoader
may be useless
-
DefaultLoader
Creates a newDefaultLoader
that will use the suppliedProvider
s andAmbiguityHandler
.The new
DefaultLoader
will returnthis
from itsparent()
method.- Parameters:
providers
- theProvider
s to use; may benull
in which caseProvider
s will be discovered using theServiceLoader
mechanism; may be empty in which case the newDefaultLoader
may be uselessambiguityHandler
- theAmbiguityHandler
to use; may benull
in which case anAmbiguityHandler
will be discovered using theServiceLoader
mechanism
-
-
Method Details
-
close
Clears any caches used by thisDefaultLoader
.This
DefaultLoader
remains valid to use.- Specified by:
close
in 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 benull
in which casethis
will be returned- Returns:
- a
DefaultLoader
that uses the additionalProvider
- Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoader
to 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 additionalProvider
s; may benull
or empty in which casethis
will be returned- Returns:
- a
DefaultLoader
that uses the additionalProvider
s - Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoader
to 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 benull
in which caseProvider
s will be loaded using theServiceLoader
class- Returns:
- a
DefaultLoader
that uses only the suppliedProvider
- Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoader
to 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
- theProvider
s; may benull
or empty in which caseProvider
s will be loaded using theServiceLoader
class- Returns:
- a
DefaultLoader
that uses only the suppliedProvider
s - Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoader
to return) but is deterministic. - Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
with
Returns aDefaultLoader
that uses the suppliedAmbiguityHandler
.- Parameters:
ambiguityHandler
- theAmbiguityHandler
; must not benull
- Returns:
- a
DefaultLoader
that uses the suppliedAmbiguityHandler
- Throws:
NullPointerException
- ifambiguityHandler
isnull
- Idempotency:
- This method is not idempotent (it usually creates a
new
DefaultLoader
to 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 unmodifiableCollection
ofProvider
s that thisDefaultLoader
will use to supply objects.This method never returns
null
.- Returns:
- an unmodifiable
Collection
ofProvider
s that thisDefaultLoader
will 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
AmbiguityHandler
associated 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 theLoader
serving as the parent of thisDefaultLoader
.The "root"
DefaultLoader
returns itself from itsparent()
implementation.This method never returns
null
.- Specified by:
parent
in interfaceLoader<T>
- Returns:
- the non-
null
Loader
serving as the parent of thisDefaultLoader
; may be thisDefaultLoader
itself - 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 thePath
with which thisDefaultLoader
was created.The
Path
that is returned by this method is not guaranteed to be absolute.The
Path
that is returned by this method will be equal to a transliterated version of thePath
that was supplied to theload(Path)
method of thisDefaultLoader
's parent that resulted in thisDefaultLoader
's creation.- Specified by:
path
in interfaceLoader<T>
- Returns:
- the non-
null
Path
with which thisDefaultLoader
was 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 absolutePath
representing thePath
with which thisDefaultLoader
was created.The
Path
that is returned by this method is guaranteed to be absolute.The
Path
that is returned by this method will be equal to a transliterated and absolute version of thePath
that was supplied to theload(Path)
method of thisDefaultLoader
's parent that resulted in thisDefaultLoader
's creation.- Specified by:
absolutePath
in interfaceLoader<T>
- Returns:
- the non-
null
absolutePath
representing thePath
with which thisDefaultLoader
was 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.Determinism
suitable for thisDefaultLoader
.- Specified by:
determinism
in interfaceOptionalSupplier<T>
- Returns:
- a
OptionalSupplier.Determinism
suitable 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 aDefaultLoader
that can supply environmental objects that are suitable for the suppliedpath
.This method never returns
null
.The
DefaultLoader
that is returned may returnnull
from itsget()
method. Additionally, theDefaultLoader
that is returned may throwNoSuchElementException
orUnsupportedOperationException
from itsget()
method.- Specified by:
load
in interfaceLoader<T>
- Type Parameters:
U
- the type of the suppliedPath
and the type of the returnedDefaultLoader
- Parameters:
path
- thePath
for which aDefaultLoader
should be returned; must not benull
- Returns:
- a
DefaultLoader
capable of supplying environmental objects suitable for the suppliedpath
; nevernull
- Throws:
NullPointerException
- ifpath
isnull
IllegalArgumentException
- 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.
-