Class Processors
InvocableMap.EntryProcessor
DSL.
Contains factory methods and entry processor classes that are used to
implement functionality exposed via different variants of NamedCache
API.
- Since:
- 14.1.1.0
- Author:
- mk 2019.07.26
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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, T, R>
InvocableMap.EntryProcessor<K, V, R> extract
(ValueExtractor<? super T, ? extends R> extractor) Construct an extract processor based on the specifiedValueExtractor
.static <K,
V, R> InvocableMap.EntryProcessor <K, V, R> Construct an extract processor for a given property or method name.static <K,
V, N extends Number>
InvocableMap.EntryProcessor<K, V, N> 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>
InvocableMap.EntryProcessor<K, V, N> 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>
InvocableMap.EntryProcessor<K, V, N> 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>
InvocableMap.EntryProcessor<K, V, N> 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> 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> 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> 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, Boolean> remove()
Construct a remove processor that unconditionally removes an InvocableMap entry.static <K,
V> InvocableMap.EntryProcessor <K, V, V> remove
(boolean fReturn) Construct a remove processor that unconditionally removes an InvocableMap entry, and optionally returns the removed value.static <K,
V> InvocableMap.EntryProcessor <K, V, V> 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> 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> 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, 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, 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> InvocableMap.EntryProcessor <K, V, Void> touch()
Construct a touch processor.static <K,
V, T> InvocableMap.EntryProcessor <K, V, Boolean> update
(ValueUpdater<V, T> updater, T value) Construct an update processor based on the specifiedValueUpdater
.static <K,
V, T> InvocableMap.EntryProcessor <K, V, Boolean> Construct an update processor for a given method name.static <K,
V extends Versionable>
InvocableMap.EntryProcessor<K, V, V> 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>
InvocableMap.EntryProcessor<K, V, V> 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>
InvocableMap.EntryProcessor<K, V, V> 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>
InvocableMap.EntryProcessor<K, V, V> 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).
-
Constructor Details
-
Processors
public Processors()
-
-
Method Details
-
asynchronous
public static <K,V, InvocableMap.EntryProcessor<K,R> V, asynchronousR> (InvocableMap.EntryProcessor<K, V, R> processor) Construct an asynchronous processor for a given processor.- Type Parameters:
K
- the type of the Map entry keyV
- the type of the Map entry valueR
- the type of value returned by the EntryProcessor- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
- Returns:
- an aynchronous processor for a given processor
- See Also:
-
asynchronous
public static <K,V, InvocableMap.EntryProcessor<K,R> V, asynchronousR> (InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId) Construct an asynchronous processor for a given processor with unit-of-order id.- Type Parameters:
K
- the type of the Map entry keyV
- the type of the Map entry valueR
- the type of value returned by the EntryProcessor- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processor- Returns:
- an aynchronous processor for a given processor with unit-of-order id
- See Also:
-
singleEntryAsynchronous
public static <K,V, InvocableMap.EntryProcessor<K,R> V, singleEntryAsynchronousR> (InvocableMap.EntryProcessor<K, V, R> processor) Construct a single entry asynchronous processor for a given processor.- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
- Returns:
- a single entry asynchronous processor for a given processor
- See Also:
-
singleEntryAsynchronous
public static <K,V, InvocableMap.EntryProcessor<K,R> V, singleEntryAsynchronousR> (InvocableMap.EntryProcessor<K, V, R> processor, int iUnitOrderId) Construct a single entry asynchronous for a given processor with unit-of-order id.- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processor- Returns:
- a single entry asynchronous processor for a given processor unit-of-order id
- See Also:
-
streamingAsynchronous
public static <K,V, InvocableMap.EntryProcessor<K,R> V, streamingAsynchronousR> (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.Important Note: All provided callbacks must be non-blocking. For example, any use of
NamedCache
API is completely disallowed.- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
onPartial
- a user-defined callback that will be called for each partial result- Returns:
- a streaming asynchronous processor for a given processor and one or more callbacks
- See Also:
-
streamingAsynchronous
public static <K,V, InvocableMap.EntryProcessor<K,R> V, streamingAsynchronousR> (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.Important Note: All provided callbacks must be non-blocking. For example, any use of
NamedCache
API is completely disallowed.- Parameters:
processor
- the underlyingInvocableMap.EntryProcessor
iUnitOrderId
- the unit-of-order id for this processoronPartial
- a user-defined callback that will be called for each partial result- Returns:
- a streaming asynchronous processor for a given processor and one or more callbacks
- See Also:
-
composite
public static <K,V> InvocableMap.EntryProcessor<K,V, compositeObject> (InvocableMap.EntryProcessor<K, V, ?>[] aProcessor) Construct a composite processor for the specified array of individual entry processors.The result of the composite processor execution is an array of results returned by the individual EntryProcessor invocations.
- Type Parameters:
K
- the type of the Map entry keyV
- the type of the Map entry value- Parameters:
aProcessor
- the entry processor array- Returns:
- a composite processor for the specified array of individual entry processors.
- See Also:
-
conditional
public static <K,V, InvocableMap.EntryProcessor<K,T> V, conditionalT> (Filter<V> filter, InvocableMap.EntryProcessor<K, V, T> processor) Construct a conditional processor for a specified filter and the 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.
- Type Parameters:
K
- the type of the Map entry keyV
- the type of the Map entry valueT
- the type of value returned by the EntryProcessor- Parameters:
filter
- the filterprocessor
- the entry processor- Returns:
- a conditional processor for a specified filter and the processor.
- See Also:
-
put
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. The result of the process invocation does not return any result.- Type Parameters:
V
- the type of the Map entry value- Parameters:
filter
- the filter to evaluate an entryvalue
- a value to update an entry with- Returns:
- a put processor that updates an entry with a new value if and only if the filter applied to the entry evaluates to true
-
put
public static <K,V> InvocableMap.EntryProcessor<K,V, putV> (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. This processor optionally returns the current value as a result of the invocation if it has not been updated (the filter evaluated to false).- Type Parameters:
V
- the type of the Map entry value- Parameters:
filter
- 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 updated- Returns:
- a put processor that updates an entry with a new value if and only if the filter applied to the entry evaluates to true.
-
putAll
public static <K,V> InvocableMap.EntryProcessor<K,V, putAllV> (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. The new value is extracted from the specified map based on the entry's key.- Type Parameters:
K
- the type of the Map entry keyV
- the type of the Map entry value- Parameters:
filter
- the filter to evaluate all supplied entriesmap
- a map of values to update entries with- Returns:
- a putAll processor that updates an entry with a new value if and only if the filter applied to the entry evaluates to true.
-
remove
Construct a remove processor that unconditionally removes an InvocableMap entry. The invocation of the created processor does not return any result.- Returns:
- a remove processor that unconditionally removes an InvocableMap entry
-
remove
Construct a remove processor that unconditionally removes an InvocableMap entry, and optionally returns the removed value.- Parameters:
fReturn
- the flag specifying whether to return the value that was removed- Returns:
- a remove processor that unconditionally removes an InvocableMap entry
-
remove
Construct a remove processor that removes an InvocableMap entry if and only if the filter applied to the entry evaluates to true. The invocation of the created processor does not return any result. Note: If the goal is to remove entries from a map based on a certain criteria, it is significantly more efficient to pass the processor created by theremove()
method toInvocableMap.invokeAll(Filter, EntryProcessor)
. That way filtering will be performed ahead of time, using any available indexes for optimization, so the number of entries the processor is executed against will be reduced. The processor returned by this method should only be used when that is not possible.- Parameters:
filter
- the filter to evaluate an entry- Returns:
- a remove processor that removes an InvocableMap entry if and only if the filter applied to the entry evaluates to true.
-
remove
Construct a remove processor that removes an InvocableMap entry if and only if the filter applied to the entry evaluates to true. This processor may optionally return the current value as a result of the invocation if it has not been removed (the filter evaluated to false). Note: If the goal is to remove entries from a map based on a certain criteria, it is significantly more efficient to pass the processor created by theremove()
method toInvocableMap.invokeAll(Filter, EntryProcessor)
. That way filtering will be performed ahead of time, using any available indexes for optimization, so the number of entries the processor is executed against will be reduced. The processor returned by this method should only be used when that is not possible.- Parameters:
filter
- the filter to evaluate an entryfReturn
- specifies whether or not the processor should return the current value if it has not been removed- Returns:
- a remove processor that removes an InvocableMap entry if and only if the filter applied to the entry evaluates to true.
-
extract
public static <K,V, InvocableMap.EntryProcessor<K,T, R> V, extractR> (ValueExtractor<? super T, ? extends R> extractor) Construct an extract processor based on the specifiedValueExtractor
.- Parameters:
extractor
- a Extractor object; passing null is equivalent to using theIdentityExtractor
- Returns:
- an extract processor based on the specified extractor.
- See Also:
-
extract
Construct an extract processor for a given property or method name.- Parameters:
sName
- a property or method name to make aValueExtractor
for; this parameter can also be a dot-delimited sequence of names which would result in an ExtractorProcessor based on theChainedExtractor
that is based on an array of correspondingValueExtractor
objects- Returns:
- an extract processor for a given property or method name
- See Also:
-
increment
public static <K,V, InvocableMap.EntryProcessor<K,N extends Number> V, incrementN> (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. The Java type of the numInc parameter will dictate the Java type of the original and the new value.- Parameters:
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 incremented- Returns:
- an increment processor
- See Also:
-
increment
public static <K,V, InvocableMap.EntryProcessor<K,N extends Number> V, incrementN> (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. The Java type of the numInc parameter will dictate the Java type of the original and the new value.- Parameters:
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 incremented- Returns:
- an increment processor
- See Also:
-
multiply
public static <K,V, InvocableMap.EntryProcessor<K,N extends Number> V, multiplyN> (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. The Java type of the original property value will dictate the way the specified factor is interpreted. For example, applying a factor of Double(0.5) to a property value of Integer(4) will result in a new property value of Integer(2).
If the original property value is null, the Java type of the numFactor parameter will dictate the Java type of the new value.- Parameters:
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 multiplied- Returns:
- a multiply processor that will multiply a property value by a specified factor, returning either the old or the new value as specified
- See Also:
-
multiply
public static <K,V, InvocableMap.EntryProcessor<K,N extends Number> V, multiplyN> (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. The Java type of the original property value will dictate the way the specified factor is interpreted. For example, applying a factor of Double(0.5) to a property value of Integer(4) will result in a new property value of Integer(2).
If the original property value is null, the Java type of the numFactor parameter will dictate the Java type of the new value.- Parameters:
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 multiplied- Returns:
- a multiply processor that will multiply a property value by a specified factor, returning either the old or the new value as specified
- See Also:
-
preload
Construct the preload request processor.- Returns:
- a preload request processor
- See Also:
-
priority
public static <K,V, InvocableMap.EntryProcessor<K,T> V, priorityT> (InvocableMap.EntryProcessor<K, V, T> processor) Construct a priority processor for a given processor.- Parameters:
processor
- the processor wrapped by this priority processor- Returns:
- a priority processor.
- See Also:
-
manipulate
Construct a property manipulate processor for the specified property name.- Parameters:
sName
- a property name- Returns:
- a property manipulate processor for the specified property name
- See Also:
-
manipulate
Construct a property manipulate processor for the specified property name.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).
- Parameters:
sName
- a property namefUseIs
- if true, the getter method will be prefixed with "is" rather than "get"- Returns:
- a property manipulate processor for the specified property name
- See Also:
-
script
public static <K,V, InvocableMap.EntryProcessor<K,R> V, scriptR> (String sLanguage, String sName, Object... aoArgs) Construct an EntryProcessor that is implemented in a script using the specified language.- Type Parameters:
K
- the type of key that theInvocableMap.EntryProcessor
will receiveV
- the type of value that theInvocableMap.EntryProcessor
will receiveR
- the type of result that theInvocableMap.EntryProcessor
will return- Parameters:
sLanguage
- the string specifying one of the supported languagessName
- the name of theInvocableMap.EntryProcessor
that needs to be evaluatedaoArgs
- the arguments to be passed to theInvocableMap.EntryProcessor
- Returns:
- An instance of script processor
- Throws:
ScriptException
- if thescript
cannot be loaded or any errors occur during its executionIllegalArgumentException
- if the specified language is not supported- See Also:
-
touch
Construct a touch processor.- Returns:
- a touch processor
- See Also:
-
update
public static <K,V, InvocableMap.EntryProcessor<K,T> V, updateBoolean> (ValueUpdater<V, T> updater, T value) Construct an update processor based on the specifiedValueUpdater
.- Parameters:
updater
- aValueUpdater
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 with- Returns:
- an update processor
- See Also:
-
update
Construct an update processor for a given method name. The method must have a single parameter of a Java type compatible with the specified value type.- Parameters:
sMethod
- a method name to make anValueUpdater
for; this parameter can also be a dot-delimited sequence of method names which would result in using aCompositeUpdater
value
- the value to update the target entry with- Returns:
- an update processor for a given method name
- See Also:
-
versionedPut
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). The result of the process invocation does not return any result.- Parameters:
oValue
- a Versionable value to update an entry with- Returns:
- a versioned put
- See Also:
-
versionedPut
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V, versionedPutV> (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. This processor optionally returns the current value as a result of the invocation if it has not been updated (the versions did not match).- Parameters:
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 updated- Returns:
- a versioned put
- See Also:
-
versionedPutAll
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V, versionedPutAllV> (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). The result of the process invocation does not return any result.- Parameters:
map
- a map of values to update entries with- Returns:
- a versioned putAll processor
- See Also:
-
versionedPutAll
public static <K,V extends Versionable> InvocableMap.EntryProcessor<K,V, versionedPutAllV> (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). This processor optionally returns a map of entries that have not been updated (the versions did not match).- Parameters:
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 updated- Returns:
- a versioned putAll processor
- See Also:
-