public class Processors extends Object
InvocableMap.EntryProcessor
DSL.
Contains factory methods and entry processor classes that are used to
implement functionality exposed via different variants of NamedCache
API.
Constructor and Description |
---|
Processors() |
Modifier and Type | Method and Description |
---|---|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
asynchronous(InvocableMap.EntryProcessor<K,V,R> processor)
Construct an asynchronous processor for a given processor.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
asynchronous(InvocableMap.EntryProcessor<K,V,R> processor,
int iUnitOrderId)
Construct an asynchronous processor for a given processor with
unit-of-order id.
|
static <K,V> InvocableMap.EntryProcessor<K,V,Object> |
composite(InvocableMap.EntryProcessor<K,V,?>[] aProcessor)
Construct a composite processor for the specified array of individual
entry processors.
|
static <K,V,T> InvocableMap.EntryProcessor<K,V,T> |
conditional(Filter<V> filter,
InvocableMap.EntryProcessor<K,V,T> processor)
Construct a conditional processor for a specified filter and the
processor.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
extract(String sName)
Construct an extract processor for a given property or method name.
|
static <K,V,T,R> InvocableMap.EntryProcessor<K,V,R> |
extract(ValueExtractor<? super T,? extends R> extractor)
Construct an extract processor based on the specified
ValueExtractor . |
static <K,V,N extends Number> |
increment(PropertyManipulator manipulator,
N numInc,
boolean fPostIncrement)
Construct an increment processor that will increment a property
value by a specified amount, returning either the old or the new value
as specified.
|
static <K,V,N extends Number> |
increment(String sName,
N numInc,
boolean fPostIncrement)
Construct an increment processor that will increment a property
value by a specified amount, returning either the old or the new value
as specified.
|
static <V,R> PropertyManipulator<V,R> |
manipulate(String sName)
Construct a property manipulate processor for the specified property name.
|
static <V,R> PropertyManipulator<V,R> |
manipulate(String sName,
boolean fUseIs)
Construct a property manipulate processor for the specified property name.
|
static <K,V,N extends Number> |
multiply(PropertyManipulator<V,N> manipulator,
N numFactor,
boolean fPostFactor)
Construct a multiply processor that will multiply a property
value by a specified factor, returning either the old or the new value
as specified.
|
static <K,V,N extends Number> |
multiply(String sName,
N numFactor,
boolean fPostFactor)
Construct a multiply processor that will multiply a property
value by a specified factor, returning either the old or the new value
as specified.
|
static <K,V> InvocableMap.EntryProcessor<K,V,V> |
preload()
Construct the preload request processor.
|
static <K,V,T> InvocableMap.EntryProcessor<K,V,T> |
priority(InvocableMap.EntryProcessor<K,V,T> processor)
Construct a priority processor for a given processor.
|
static <K,V> InvocableMap.EntryProcessor<K,V,V> |
put(Filter filter,
V value)
Construct a put processor that updates an entry with a new value if
and only if the filter applied to the entry evaluates to true.
|
static <K,V> InvocableMap.EntryProcessor<K,V,V> |
put(Filter filter,
V value,
boolean fReturn)
Construct a put processor that updates an entry with a new value if
and only if the filter applied to the entry evaluates to true.
|
static <K,V> InvocableMap.EntryProcessor<K,V,V> |
putAll(Filter filter,
Map<? extends K,? extends V> map)
Construct a putAll processor that updates an entry with a
new value if and only if the filter applied to the entry evaluates to
true.
|
static <K,V> InvocableMap.EntryProcessor<K,V,V> |
remove(Filter filter)
Construct a remove processor that removes an InvocableMap
entry if and only if the filter applied to the entry
evaluates to true.
|
static <K,V> InvocableMap.EntryProcessor<K,V,V> |
remove(Filter filter,
boolean fReturn)
Construct a remove processor that removes an InvocableMap
entry if and only if the filter applied to the entry evaluates to true.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
script(String sLanguage,
String sName,
Object... aoArgs)
Construct an EntryProcessor that is implemented in a script using
the specified language.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
singleEntryAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor)
Construct a single entry asynchronous processor for a given processor.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
singleEntryAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor,
int iUnitOrderId)
Construct a single entry asynchronous for a given processor
with unit-of-order id.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
streamingAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor,
Consumer<? super Map.Entry<? extends K,? extends R>> onPartial)
Construct a streaming asynchronous processor for a given processor
and one or more callbacks.
|
static <K,V,R> InvocableMap.EntryProcessor<K,V,R> |
streamingAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor,
int iUnitOrderId,
Consumer<? super Map.Entry<? extends K,? extends R>> onPartial)
Construct a streaming asynchronous processor for a given processor
and one or more callbacks.
|
static <K,V> InvocableMap.EntryProcessor<K,V,Void> |
touch()
Construct a touch processor.
|
static <K,V,T> InvocableMap.EntryProcessor<K,V,Boolean> |
update(String sMethod,
T value)
Construct an update processor for a given method name.
|
static <K,V,T> InvocableMap.EntryProcessor<K,V,Boolean> |
update(ValueUpdater<V,T> updater,
T value)
Construct an update processor based on the specified
ValueUpdater . |
static <K,V extends Versionable> |
versionedPut(V oValue)
Construct a versioned put processor that updates an entry with
a new value if and only if the version of the new value matches
to the version of the current entry's value (which must exist).
|
static <K,V extends Versionable> |
versionedPut(V oValue,
boolean fAllowInsert,
boolean fReturn)
Construct a versioned put processor that updates an entry with
a new value if and only if the version of the new value matches
to the version of the current entry's value.
|
static <K,V extends Versionable> |
versionedPutAll(Map<? extends K,? extends V> map)
Construct a versioned putAll processor that updates an entry with
a new value if and only if the version of the new value matches
to the version of the current entry's value (which must exist).
|
static <K,V extends Versionable> |
versionedPutAll(Map<? extends K,? extends V> map,
boolean fAllowInsert,
boolean fReturn)
Construct a versioned putAll processor that updates an entry with a new
value if and only if the version of the new value matches to the
version of the current entry's value (which must exist).
|
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> asynchronous(InvocableMap.EntryProcessor<K,V,R> processor)
K
- the type of the Map entry keyV
- the type of the Map entry valueR
- the type of value returned by the EntryProcessorprocessor
- the underlying InvocableMap.EntryProcessor
AsynchronousProcessor
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> asynchronous(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId)
K
- the type of the Map entry keyV
- the type of the Map entry valueR
- the type of value returned by the EntryProcessorprocessor
- the underlying InvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processorAsynchronousProcessor
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> singleEntryAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor)
processor
- the underlying InvocableMap.EntryProcessor
SingleEntryAsynchronousProcessor
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> singleEntryAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId)
processor
- the underlying InvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processorSingleEntryAsynchronousProcessor
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> streamingAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> onPartial)
Important Note: All provided callbacks must be non-blocking.
For example, any use of NamedCache
API is completely disallowed.
processor
- the underlying InvocableMap.EntryProcessor
onPartial
- a user-defined callback that will be called for each
partial resultStreamingAsynchronousProcessor
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> streamingAsynchronous(InvocableMap.EntryProcessor<K,V,R> processor, int iUnitOrderId, Consumer<? super Map.Entry<? extends K,? extends R>> onPartial)
Important Note: All provided callbacks must be non-blocking.
For example, any use of NamedCache
API is completely disallowed.
processor
- the underlying InvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processoronPartial
- a user-defined callback that will be called for each
partial resultStreamingAsynchronousProcessor
public static <K,V> InvocableMap.EntryProcessor<K,V,Object> composite(InvocableMap.EntryProcessor<K,V,?>[] aProcessor)
The result of the composite processor execution is an array of results returned by the individual EntryProcessor invocations.
K
- the type of the Map entry keyV
- the type of the Map entry valueaProcessor
- the entry processor arrayCompositeProcessor
public static <K,V,T> InvocableMap.EntryProcessor<K,V,T> conditional(Filter<V> filter, InvocableMap.EntryProcessor<K,V,T> processor)
The specified entry processor gets invoked if and only if the filter applied to the InvocableMap entry evaluates to true; otherwise the result of the process invocation will return null.
K
- the type of the Map entry keyV
- the type of the Map entry valueT
- the type of value returned by the EntryProcessorfilter
- the filterprocessor
- the entry processorConditionalProcessor
public static <K,V> InvocableMap.EntryProcessor<K,V,V> put(Filter filter, V value)
V
- the type of the Map entry valuefilter
- the filter to evaluate an entryvalue
- a value to update an entry withpublic static <K,V> InvocableMap.EntryProcessor<K,V,V> put(Filter filter, V value, boolean fReturn)
V
- the type of the Map entry valuefilter
- the filter to evaluate an entryvalue
- a value to update an entry withfReturn
- specifies whether or not the processor should return
the current value in case it has not been updatedpublic static <K,V> InvocableMap.EntryProcessor<K,V,V> putAll(Filter filter, Map<? extends K,? extends V> map)
K
- the type of the Map entry keyV
- the type of the Map entry valuefilter
- the filter to evaluate all supplied entriesmap
- a map of values to update entries withpublic static <K,V> InvocableMap.EntryProcessor<K,V,V> remove(Filter filter)
filter
- the filter to evaluate an entrypublic static <K,V> InvocableMap.EntryProcessor<K,V,V> remove(Filter filter, boolean fReturn)
filter
- the filter to evaluate an entryfReturn
- specifies whether or not the processor should return
the current value if it has not been removedpublic static <K,V,T,R> InvocableMap.EntryProcessor<K,V,R> extract(ValueExtractor<? super T,? extends R> extractor)
ValueExtractor
.extractor
- a Extractor object; passing null is equivalent
to using the IdentityExtractor
ExtractorProcessor
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> extract(String sName)
sName
- a property or method name to make a ValueExtractor
for; this parameter can also be a dot-delimited
sequence of names which would result in an
ExtractorProcessor based on the ChainedExtractor
that is based on an array of
corresponding ValueExtractor
objectsExtractorProcessor
public static <K,V,N extends Number> InvocableMap.EntryProcessor<K,V,N> increment(String sName, N numInc, boolean fPostIncrement)
sName
- the property namenumInc
- the Number representing the magnitude and sign
of the incrementfPostIncrement
- pass true to return the value as it was before
it was incremented, or pass false to return the
value as it is after it is incrementedNumberIncrementor
public static <K,V,N extends Number> InvocableMap.EntryProcessor<K,V,N> increment(PropertyManipulator manipulator, N numInc, boolean fPostIncrement)
manipulator
- the Manipulator; could be nullnumInc
- the Number representing the magnitude and sign of
the incrementfPostIncrement
- pass true to return the value as it was before
it was incremented, or pass false to return the
value as it is after it is incrementedNumberIncrementor
public static <K,V,N extends Number> InvocableMap.EntryProcessor<K,V,N> multiply(String sName, N numFactor, boolean fPostFactor)
If the original property value is null, the Java type of the numFactor parameter will dictate the Java type of the new value.
sName
- the property namenumFactor
- the Number representing the magnitude and sign of
the multiplierfPostFactor
- pass true to return the value as it was before
it was multiplied, or pass false to return the
value as it is after it is multipliedNumberMultiplier
public static <K,V,N extends Number> InvocableMap.EntryProcessor<K,V,N> multiply(PropertyManipulator<V,N> manipulator, N numFactor, boolean fPostFactor)
If the original property value is null, the Java type of the numFactor parameter will dictate the Java type of the new value.
manipulator
- the Manipulator; could be nullnumFactor
- the Number representing the magnitude and sign of
the multiplierfPostFactor
- pass true to return the value as it was before
it was multiplied, or pass false to return the
value as it is after it is multipliedNumberMultiplier
public static <K,V> InvocableMap.EntryProcessor<K,V,V> preload()
PreloadRequest
public static <K,V,T> InvocableMap.EntryProcessor<K,V,T> priority(InvocableMap.EntryProcessor<K,V,T> processor)
processor
- the processor wrapped by this priority processorPriorityProcessor
public static <V,R> PropertyManipulator<V,R> manipulate(String sName)
sName
- a property namePropertyManipulator
public static <V,R> PropertyManipulator<V,R> manipulate(String sName, boolean fUseIs)
This constructor assumes that the corresponding property getter will have a name of either ("get" + sName) or ("is + sName) and the corresponding property setter's name will be ("set + sName).
sName
- a property namefUseIs
- if true, the getter method will be prefixed with "is"
rather than "get"PropertyManipulator
public static <K,V,R> InvocableMap.EntryProcessor<K,V,R> script(String sLanguage, String sName, Object... aoArgs)
K
- the type of key that the InvocableMap.EntryProcessor
will receiveV
- the type of value that the InvocableMap.EntryProcessor
will receiveR
- the type of result that the InvocableMap.EntryProcessor
will returnsLanguage
- the string specifying one of the supported languagessName
- the name of the InvocableMap.EntryProcessor
that needs to
be evaluatedaoArgs
- the arguments to be passed to the InvocableMap.EntryProcessor
ScriptException
- if the script
cannot be loaded or
any errors occur during its executionIllegalArgumentException
- if the specified language is not supportedScriptProcessor
public static <K,V> InvocableMap.EntryProcessor<K,V,Void> touch()
TouchProcessor
public static <K,V,T> InvocableMap.EntryProcessor<K,V,Boolean> update(ValueUpdater<V,T> updater, T value)
ValueUpdater
.updater
- a ValueUpdater
object; passing null will simpy
replace the entry's value with the specified one
instead of updating itvalue
- the value to update the target entry withUpdaterProcessor
public static <K,V,T> InvocableMap.EntryProcessor<K,V,Boolean> update(String sMethod, T value)
sMethod
- a method name to make an ValueUpdater
for; this parameter can also be a dot-delimited sequence
of method names which would result in using a
CompositeUpdater
value
- the value to update the target entry withUpdaterProcessor
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V,V> versionedPut(V oValue)
oValue
- a Versionable value to update an entry withVersionedPut
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V,V> versionedPut(V oValue, boolean fAllowInsert, boolean fReturn)
oValue
- a value to update an entry withfAllowInsert
- specifies whether or not an insert should be
allowed (no currently existing value)fReturn
- specifies whether or not the processor should
return the current value in case it has not been
updatedVersionedPut
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V,V> versionedPutAll(Map<? extends K,? extends V> map)
map
- a map of values to update entries withVersionedPutAll
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V,V> versionedPutAll(Map<? extends K,? extends V> map, boolean fAllowInsert, boolean fReturn)
map
- a map of values to update entries withfAllowInsert
- specifies whether or not an insert should be
allowed (no currently existing value)fReturn
- specifies whether or not the processor should
return the entries that have not been updatedVersionedPutAll