@groovy.util.logging.Slf4j @groovy.transform.CompileStatic class KeyExtractor extends java.lang.Object
Utility class for extracting and comparing keys from channel items using closures. This class provides centralized logic for closure-based key extraction with proper error handling, validation, and support for composite (multi-part) keys.
| Constructor and description |
|---|
KeyExtractor() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.lang.Object |
extractKey(java.lang.Object item, groovy.lang.Closure keyExtractor, java.lang.String operatorName)Extract a key from an item using a closure, with error handling. |
|
static boolean |
keysEqual(java.lang.Object key1, java.lang.Object key2)Compare two keys for equality. |
|
static void |
validateKeyExtractor(groovy.lang.Closure keyExtractor, java.lang.String operatorName)Validate that a keyExtractor closure has the correct arity (parameter count). |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait() |
Extract a key from an item using a closure, with error handling. This method safely invokes the keyExtractor closure on the item, handling null returns and exceptions appropriately. List keys are automatically wrapped in CompositeKey for proper equality semantics.
item - The channel item to extract a key fromkeyExtractor - The closure that extracts the keyoperatorName - The name of the calling operator (for error messages)Compare two keys for equality.
key1 - The first keykey2 - The second keyValidate that a keyExtractor closure has the correct arity (parameter count). A valid keyExtractor must accept at least one parameter (the channel item). Closures with more than 2 parameters will generate a warning as they may indicate incorrect usage.
keyExtractor - The closure to validateoperatorName - The name of the calling operator (for error messages)