T
- type of the target object to extract the value frompublic abstract class ValueExtractor<T> extends Object
MapAttributeConfig attributeConfig = new MapAttributeConfig();
extractorConfig.setName("currency");
extractorConfig.setExtractor("com.bank.CurrencyExtractor");
How to register the newly-defined attribute in a configuration of a Map?
MapConfig mapConfig = (...);
mapConfig.addMapAttributeConfig(attributeConfig);
Extractors may be also defined in the XML configuration.
Please, bear in mind that an extractor may not be added after the map has been instantiated.
All extractor have to be defined upfront in the map's initial configuration.
Reflection-based extraction is the default mechanism - ValueExtractors are an alternative way of extracting
attribute values from object.Constructor and Description |
---|
ValueExtractor() |
Modifier and Type | Method and Description |
---|---|
abstract void |
extract(T target,
ValueCollector collector)
Extracts a value from the given target object.
|
public abstract void extract(T target, ValueCollector collector)
class Swap {
Leg legs[2];
}
class Leg {
String currency;
}
Let's assume that we want to extract currencies of all legs from a single Swap object. Each Swap has two Legs
so there are two currencies too. In order to return both values from the extraction operation just collect them
separately using the ValueCollector. Collecting multiple values in such a way allows us to operate on multiple
"reduced" values as if they were single-values.
Let's have look at the following query 'swapCurrency = EUR', assuming that we registered a custom extractor to
extract currencies from a swap under the name swapCurrency.
It will return up to two currencies, but the default evaluation semantics is that it is enough if a single
value evaluates the condition to true to return the Swap from the query.target
- object to extract the value fromcollector
- collector of the extracted value(s)ValueCollector
Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.