java.lang.Object
org.microbean.loader.spi.AbstractProvider
org.microbean.loader.spi.AbstractTreeBasedProvider<TreeNode>
org.microbean.loader.jackson.JacksonProvider
- All Implemented Interfaces:
Provider
- Direct Known Subclasses:
InputStreamJacksonProvider
A partial
AbstractTreeBasedProvider
implementation backed
by Jackson.- Author:
- Laird Nelson
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a newJacksonProvider
.protected
JacksonProvider
(Type lowerBound) Creates a newJacksonProvider
. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Returnstrue
if the suppliednode
isnull
, absent or synthetic.final TreeNode
Returns the child node of the supplied parentnode
identified by the suppliedindex
, ornull
if either the child does not exist ornode
is not a list node.final TreeNode
Returns the child node of the supplied parentnode
identified by the suppliedname
, ornull
if either the child does not exist ornode
is not a map node.final boolean
Returnstrue
if the suppliednode
represents a list or an array, and therefore theAbstractTreeBasedProvider.get(Object, int)
method is likely to be relevant.final boolean
Returnstrue
if the suppliednode
represents a map, and therefore theAbstractTreeBasedProvider.get(Object, String)
method is likely to be relevant.Returns anIterator
over the names of the suppliednode
's child nodes, or an emptyIterator
if the suppliednode
is not a map node.final boolean
Returnstrue
if the suppliednode
isnull
or represents an explicitly setnull
value.protected abstract ObjectCodec
objectCodec
(Loader<?> requestor, Path<? extends Type> absolutePath) Returns anObjectCodec
suitable for the combination of the suppliedLoader
andPath
, ornull
if there is no suchObjectCodec
.protected TreeNode
qualifiers
(TreeNode node) Returns a node possibly containing qualifiers applicable to the supplied node, ornull
.protected BiFunction<? super TreeNode,
? super Type, ?> Returns aBiFunction
accepting a node and aType
and returning the result of reading an object of that type, ornull
if no suchBiFunction
could be sourced.final int
Returns the number of child nodes the suppliednode
has, which may be (and often is)0
.Methods inherited from class org.microbean.loader.spi.AbstractTreeBasedProvider
container, find, path, path, qualifiers, rootNode
Methods inherited from class org.microbean.loader.spi.AbstractProvider
get, lowerBound
-
Constructor Details
-
JacksonProvider
protected JacksonProvider()Creates a newJacksonProvider
.- See Also:
-
JacksonProvider
Creates a newJacksonProvider
.- Parameters:
lowerBound
- the lower type bound of thisJacksonProvider
implementation; may benull
-
-
Method Details
-
size
Description copied from class:AbstractTreeBasedProvider
Returns the number of child nodes the suppliednode
has, which may be (and often is)0
.If the supplied
null
isnull
, absent or a scalar, an override of this method must return0
.- Specified by:
size
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the parent node; may benull
in which case0
must be returned- Returns:
- the number of child nodes the supplied
node
has, which may be (and often is)0
-
names
Description copied from class:AbstractTreeBasedProvider
Returns anIterator
over the names of the suppliednode
's child nodes, or an emptyIterator
if the suppliednode
is not a map node.- Specified by:
names
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the parent node; may benull
in which case an emptyIterator
must be returned- Returns:
- an
Iterator
; nevernull
-
get
Description copied from class:AbstractTreeBasedProvider
Returns the child node of the supplied parentnode
identified by the suppliedname
, ornull
if either the child does not exist ornode
is not a map node.- Specified by:
get
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the parent node; may benull
in which casenull
must be returnedname
- the name of the child; must not benull
- Returns:
- the child node of the supplied parent
node
identified by the suppliedname
, ornull
if either the child does not exist ornode
is not a map node
-
get
Description copied from class:AbstractTreeBasedProvider
Returns the child node of the supplied parentnode
identified by the suppliedindex
, ornull
if either the child does not exist ornode
is not a list node.- Specified by:
get
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the parent node; may benull
in which casenull
must be returnedindex
- the zero-based index of the child- Returns:
- the child node of the supplied parent
node
identified by the suppliedname
, ornull
if either the child does not exist ornode
is not a map node
-
absent
Description copied from class:AbstractTreeBasedProvider
Returnstrue
if the suppliednode
isnull
, absent or synthetic.- Specified by:
absent
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the node to test; may benull
in which casetrue
must be returned- Returns:
true
if the suppliednode
isnull
, absent or synthetic
-
nil
Description copied from class:AbstractTreeBasedProvider
Returnstrue
if the suppliednode
isnull
or represents an explicitly setnull
value.- Specified by:
nil
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the node to test; may benull
in which casetrue
must be returned- Returns:
true
if the suppliednode
isnull
or represents an explicitly setnull
value
-
map
Description copied from class:AbstractTreeBasedProvider
Returnstrue
if the suppliednode
represents a map, and therefore theAbstractTreeBasedProvider.get(Object, String)
method is likely to be relevant.- Specified by:
map
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the node to test; may benull
in which casefalse
must be returned- Returns:
true
if the suppliednode
represents a map, and therefore theAbstractTreeBasedProvider.get(Object, String)
method is likely to be relevant
-
list
Description copied from class:AbstractTreeBasedProvider
Returnstrue
if the suppliednode
represents a list or an array, and therefore theAbstractTreeBasedProvider.get(Object, int)
method is likely to be relevant.- Specified by:
list
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the node to test; may benull
in which casefalse
must be returned- Returns:
true
if the suppliednode
represents a list or an array, and therefore theAbstractTreeBasedProvider.get(Object, int)
method is likely to be relevant
-
qualifiers
Description copied from class:AbstractTreeBasedProvider
Returns a node possibly containing qualifiers applicable to the supplied node, ornull
.- Specified by:
qualifiers
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
node
- the node for which a corresponding qualifiers node should be returned; may benull
in which casenull
must be returned- Returns:
- a node possibly containing qualifiers applicable to the
supplied node, or
null
-
objectCodec
Returns anObjectCodec
suitable for the combination of the suppliedLoader
andPath
, ornull
if there is no suchObjectCodec
.This method is called by the
AbstractProvider.get(Loader, Path)
method in the normal course of events.- Parameters:
requestor
- theLoader
seeking aValue
; must not benull
absolutePath
- an absolutePath
for which the suppliedLoader
is seeking a value; must not benull
- Returns:
- an
ObjectCodec
suitable for the combination of the suppliedLoader
andPath
, ornull
- Idempotency:
- Implementations of this method must be idempotent, but not necessarily deterministic.
- Nullability:
- Implementations of this method may return
null
. - Thread Safety:
- Implementations of this method must be safe for concurrent use by multiple threads.
-
reader
protected BiFunction<? super TreeNode,? super Type, reader?> (Loader<?> requestor, Path<? extends Type> absolutePath) Description copied from class:AbstractTreeBasedProvider
Returns aBiFunction
accepting a node and aType
and returning the result of reading an object of that type, ornull
if no suchBiFunction
could be sourced.- Specified by:
reader
in classAbstractTreeBasedProvider<TreeNode>
- Parameters:
requestor
- theLoader
currently executing a request; must not benull
absolutePath
- the path being requested; must not benull
and must be absolute- Returns:
- a
BiFunction
accepting a node and aType
and returning the result of reading an object of that type, ornull
if no suchBiFunction
could be sourced
-