IN
- is the generic input-type
.VALUE
- is the generic value-type
public interface PojoPathFunction<IN,VALUE>
PojoPathFunction
that allows to add custom functionality to a
PojoPathNavigator
. PojoPathFunction
is registered
in a
PojoPathFunctionManager
under a specific name ( functionName
). The PojoPathFunction
itself
does NOT contain that name and gets this name back as parameter when it is invoked. Therefore the same
PojoPathFunction
instance can be registered
with
different names and can behave different according to the name it was invoked for. Modifier and Type | Field and Description |
---|---|
static char |
FUNCTION_NAME_PREFIX
This is the prefix used to indicate a
PojoPathFunction in a PojoPath . |
Modifier and Type | Method and Description |
---|---|
VALUE |
create(IN input,
String functionName,
PojoPathContext context)
This method creates an appropriate new value.
|
VALUE |
get(IN input,
String functionName,
PojoPathContext context)
This method gets the value of this function.
|
Class<IN> |
getInputClass()
This method gets the input-type of this function.
|
Class<VALUE> |
getValueClass()
This method gets the output-type (or return-type) of this function.
|
boolean |
isDeterministic()
This method determines if this
PojoPathFunction is deterministic. |
VALUE |
set(IN input,
String functionName,
VALUE value,
PojoPathContext context)
|
static final char FUNCTION_NAME_PREFIX
PojoPathFunction
in a PojoPath
. The value (64) will
never change. It is NOT necessary to use this constant to construct a PojoPath
. segment
@myFunction
as part of a PojoPath
such as
foo.bar.@myFunction
indicates that the PojoPathFunction
named
myFunction
should be invoked to
get
, create
or
set
the value for @myFunction
based on the result
retrieved for foo.bar
.PojoPath.getFunction()
,
Constant Field Valuesboolean isDeterministic()
PojoPathFunction
is deterministic. In this case it has to guarantee that
repetitive calls of get
with the same (unmodified) actual
Pojo
will produce the same result. PojoPathFunction
should be deterministic. However in some cases the calculation of a
PojoPathFunction
may depend on the current time or a random value and will therefore be indeterministic.
PojoPathFunction
is indeterministic, the caching
will disabled for
its result and further traversals. true
if this function is deterministic, false
otherwise.Class<IN> getInputClass()
Pojo
s this
function operates on.Class<VALUE> getValueClass()
input
- Pojo
.VALUE get(IN input, String functionName, PojoPathContext context)
PojoPathNavigator
.
get
independent of the
PojoPathMode
. A regular implementation should only return what is already there. However in specific cases
this may NOT (initially) be available from the given Pojo
actual
and
therefore be retrieved from somewhere else (e.g. a database using a primary key given via a
property
of the given context
). Further it can be legal to modify
the actual
Pojo
e.g. by attaching the externally retrieved result.input
- is the actual Pojo
where this function is invoked on. Typically the
returned value should be retrieved via this object.functionName
- is the name under which this PojoPathFunction
was invoked via the
PojoPathNavigator
excluding the FUNCTION_NAME_PREFIX
.context
- is the PojoPathContext
providing additional context information. Objects traversed between
actual
and the returned value should be recognized
via the recognizer
.null
if NOT available.VALUE create(IN input, String functionName, PojoPathContext context)
PojoPathNavigator
.
get
if the mode is
PojoPathMode.CREATE_IF_NULL
after get
returned null
.
pojo-factory
. Further in most cases the created value instance will be attached to the given actual
Pojo
.input
- is the actual Pojo
where this function is invoked on. Typically the
returned value should be retrieved via this object.functionName
- is the name under which this PojoPathFunction
was invoked via the
PojoPathNavigator
excluding the FUNCTION_NAME_PREFIX
.context
- is the PojoPathContext
providing additional context information. Objects traversed between
actual
and the returned value should be recognized
via the recognizer
.null
if creation is NOT possible. However returning null
here
will cause the PojoPathNavigator
to fail with an exception.VALUE set(IN input, String functionName, VALUE value, PojoPathContext context)
value
for the given actual
Pojo
. get
should return the same value
for identical arguments.input
- is the actual Pojo
where this function is invoked on. Typically the
given value
should be set in this object.functionName
- is the name under which this PojoPathFunction
was invoked via the
PojoPathNavigator
excluding the FUNCTION_NAME_PREFIX
.value
- is the value to set.context
- is the PojoPathContext
providing additional context information. Objects traversed between
actual
and the returned value should be recognized
via the recognizer
.null
.Copyright © 2001–2016 mmm-Team. All rights reserved.