@ComponentSpecification public interface PojoPathNavigator
Pojo
reflectively according to a given PojoPath
.
PojoPathNavigator
is designed to be thread-safe and extensible. Therefore the
state is externalized to a context
that is provided as argument to the methods of
this interface.PojoPath
,
PojoDescriptorBuilder
Modifier and Type | Method and Description |
---|---|
Object |
get(Object pojo,
String pojoPath,
PojoPathMode mode,
PojoPathContext context)
This method evaluates the given
pojoPath for the given pojo using the given mode
and context . |
<TYPE> TYPE |
get(Object pojo,
String pojoPath,
PojoPathMode mode,
PojoPathContext context,
Class<TYPE> targetClass)
This method evaluates the given
pojoPath for the given pojo using the given mode
and context . |
GenericType<?> |
getType(GenericType<?> pojoType,
String pojoPath,
boolean failOnUnsafePath,
PojoPathContext context)
This method determines the result-type for the given
pojoPath starting at the given
pojoType using the given context . |
GenericType<?> |
getType(Type pojoType,
String pojoPath,
boolean failOnUnsafePath,
PojoPathContext context)
This method determines the result-type for the given
pojoPath starting at the given
pojoType using the given context . |
Map<String,Object> |
pojo2Map(Object pojo)
|
Map<String,Object> |
pojo2Map(Object pojo,
PojoPathContext context)
|
Object |
set(Object pojo,
String pojoPath,
PojoPathMode mode,
PojoPathContext context,
Object value)
This method sets the given
value for the given pojoPath in the given pojo using
the given mode and context . |
Object get(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context) throws PojoPathException, IllegalPojoPathException, PojoPathSegmentIsNullException, InstantiationFailedException
pojoPath
for the given pojo
using the given mode
and context
. It returns the result of the evaluation. caching
for repetitive calls on the same initial
pojo
, you might get wrong results if intermediate objects have changed
outside this navigator
in the
meantime.pojo
- is the initial Pojo
to operate on.pojoPath
- is the PojoPath
to navigate.mode
- is the mode
that determines how to deal with null
values.context
- is the PojoPathContext
for this operation.pojoPath
starting at the given pojo
. It
may be null
according to the given mode
.IllegalPojoPathException
- if the given pojoPath
is illegal.PojoPathSegmentIsNullException
- if an intermediate Pojo
was
null
and the given mode
disallows this.InstantiationFailedException
- if an intermediate Pojo
was
null
and should be created but the instantiation failed.PojoPathException
- if the operation failed for arbitrary reasons.<TYPE> TYPE get(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context, Class<TYPE> targetClass) throws PojoPathException, IllegalPojoPathException, PojoPathSegmentIsNullException, InstantiationFailedException, PojoPathConversionException
pojoPath
for the given pojo
using the given mode
and context
. It returns the result of the evaluation. caching
for repetitive calls on the same initial
pojo
, you might get wrong results if intermediate objects have changed
outside this navigator
in the
meantime.TYPE
- is the generic type of the result.pojo
- is the initial Pojo
to operate on.pojoPath
- is the PojoPath
to navigate.mode
- is the mode
that determines how to deal with null
values.context
- is the PojoPathContext
for this operation.targetClass
- is the required result-type.pojoPath
starting at the given pojo
. It
may be null
according to the given mode
.IllegalPojoPathException
- if the given pojoPath
is illegal.PojoPathSegmentIsNullException
- if an intermediate Pojo
was
null
and the given mode
disallows this.InstantiationFailedException
- if an intermediate Pojo
was
null
and should be created but the instantiation failed.PojoPathException
- if the operation failed for arbitrary reasons.PojoPathConversionException
- if the result is NOT compatible with the given targetClass
and could NOT be converted.GenericType<?> getType(GenericType<?> pojoType, String pojoPath, boolean failOnUnsafePath, PojoPathContext context) throws PojoPathException, IllegalPojoPathException, PojoPathUnsafeException
pojoPath
starting at the given
pojoType
using the given context
. get
is invoked on this
navigator with an instance of pojoType
the result will be an instance of the type returned by
this method. pojoPath
may be unsafe , what means that it has a
segment
that points to a property that does NOT exist for the Class
determined for the according Pojo
. In other words a PojoPath
is
unsafe if it can NOT be written as native Java method cascade without using casts in order to be
compiled. It may be illegal depending on the initial Pojo
.pojoType
- is the type of the initial Pojo
.pojoPath
- is the PojoPath
to navigate.failOnUnsafePath
- determines how to deal with unsafe PojoPath
s. If true
and the given pojoPath
is unsafe for the given pojoType
an
PojoPathUnsafeException
is thrown and if false
this method returns null
in
such case.context
- is the PojoPathContext
for this operation.pojoPath
starting at the given
pojoType
. It may be Object.class
e.g. in case an untyped
Collection
is hit. It will be null
if the given pojoPath
is
unsafe and the given mode
is PojoPathMode.RETURN_IF_NULL
.IllegalPojoPathException
- if the given pojoPath
is illegal.PojoPathUnsafeException
- if the given pojoPath
is unsafe for the given pojoType
and this is disallowed by mode
.PojoPathException
- if the operation failed for arbitrary reasons.GenericType<?> getType(Type pojoType, String pojoPath, boolean failOnUnsafePath, PojoPathContext context) throws PojoPathException, IllegalPojoPathException, PojoPathUnsafeException
pojoPath
starting at the given
pojoType
using the given context
. get
is invoked on this
navigator with an instance of pojoType
the result will be an instance of the type returned by
this method. pojoPath
may be unsafe , what means that it has a
segment
that points to a property that does NOT exist for the Class
determined for the according Pojo
. In other words a PojoPath
is
unsafe if it can NOT be written as native Java method cascade without using casts in order to be
compiled. It may be illegal depending on the initial Pojo
.pojoType
- is the type of the initial Pojo
.pojoPath
- is the PojoPath
to navigate.failOnUnsafePath
- determines how to deal with unsafe PojoPath
s. If true
and the given pojoPath
is unsafe for the given pojoType
an
PojoPathUnsafeException
is thrown and if false
this method returns null
in
such case.context
- is the PojoPathContext
for this operation.pojoPath
starting at the given
pojoType
. It may be Object.class
e.g. in case an untyped
Collection
is hit. It will be null
if the given pojoPath
is
unsafe and the given mode
is PojoPathMode.RETURN_IF_NULL
.IllegalPojoPathException
- if the given pojoPath
is illegal.PojoPathUnsafeException
- if the given pojoPath
is unsafe for the given pojoType
and this is disallowed by mode
.PojoPathException
- if the operation failed for arbitrary reasons.Object set(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context, Object value) throws PojoPathException, IllegalPojoPathException, PojoPathSegmentIsNullException, InstantiationFailedException, PojoPathConversionException
value
for the given pojoPath
in the given pojo
using
the given mode
and context
. It acts like a
get
on the parent-path
and then setting the value
for the remaining segment
on the result. segment
points to a PojoPathFunction
the result of
its set
-method is returned.segment
points to an index,parent-path
is a
List
, Map
or array, this will be the old
value
of the given pojoPath
that has
been replaced by value
.pojo
is This will typically be the value that replaced value. It may be null
.pojo
- is the initial Pojo
to operate on.pojoPath
- is the PojoPath
to navigate.mode
- is the mode
that determines how to deal with null
values.context
- is the PojoPathContext
for this operation.value
- is the value to set. It may be null
.set
operation.IllegalPojoPathException
- if the given pojoPath
is illegal.PojoPathSegmentIsNullException
- if an intermediate Pojo
was
null
and the given mode
disallows this.InstantiationFailedException
- if an intermediate Pojo
was
null
and should be created but the instantiation failed.PojoPathException
- if the operation failed for arbitrary reasons.PojoPathConversionException
- if the given pojo
is NOT compatible with the type required
for the given pojoPath
and could NOT be converted.Map<String,Object> pojo2Map(Object pojo)
Map
reflecting the given
Pojo
. Map
will be simple
and will NOT
support size
or iteration
.pojo
- is the Pojo
to convert.Map
reflecting the given Pojo
.PojoDescriptorBuilder.pojo2Map(Object)
Map<String,Object> pojo2Map(Object pojo, PojoPathContext context)
Map
reflecting the given
Pojo
. Map
will be simple
and will NOT
support size
or iteration
.pojo
- is the Pojo
to convert.context
- is the PojoPathContext
for this operation.Map
reflecting the given Pojo
.PojoDescriptorBuilder.pojo2Map(Object)
Copyright © 2001–2016 mmm-Team. All rights reserved.