Interface Grouper<T>
- Type Parameters:
T-
public interface Grouper<T>
User applications may implement this interface in order to customize the compution of groups in cases when the modifying the
key is not possible, or when the value determined by the Group annotation needs customizing.
Grouper acts as an interceptor, passing the previously computed value in. The group passed to the first
Grouper will be that determined by @Group (if @Group is defined).
For example:
public class KXGrouper implements Grouper<String> {
// A pattern that can extract from a "kX" (e.g. k1, k2) style key
private static Pattern kPattern = Pattern.compile("(ˆk)(\\d)$");
public String computeGroup(String key, String group) {
Matcher matcher = kPattern.matcher(key);
if (matcher.matches()) {
String g = Integer.parseInt(matcher.group(2)) % 2 + "";
return g;
} else
return null;
}
public Class<String> getKeyType() {
return String.class;
}
}
You must set the
groupsEnabled property to true in your configuration in order to use groups. You can specify an order list of groupers there.
- Author:
- Pete Muir
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault ObjectcomputeGroup(T key, Object group) Compute the group for a given key
-
Method Details
-
computeGroup
-
getKeyType
-