# Business Logic — CAANMsgFinder.evaluate() [11 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.CAANMsgFinder` |
| Layer | CC/Common Component (Package: `com.fujitsu.futurity.bp.custom.common`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### CAANMsgFinder.evaluate()

This method is the core predicate-evaluation routine of the `ListMultiFilter` class, which implements the `Predicater<HashMap<String, String>>` interface. Its purpose is to perform **map-based multi-value matching**: it checks whether the value associated with a specific key in a given `HashMap` matches any entry in a pre-configured list of allowed values. In business terms, this is a **filter/predicate utility** used to determine whether a data record passes a validation rule — specifically, whether a field's value belongs to an approved set of codes.

The design pattern used here is a **generic predicate filter**. A `ListMultiFilter` instance is constructed with a target key (e.g., a status code field name) and an array of valid values (e.g., `"0"` meaning "No" or `"1"` meaning "Yes"). This instance is then passed to collection-level operations (`Items.exist`, `Items.find`, `Items.select`) which iterate over a list of maps and apply the predicate to each. The method returns `true` if the map's key-value pair matches any allowed value, and `false` otherwise.

In the larger system, this predicate is used as a building block for validation and filtering logic across screens and CBS (Component-Based Services). For example, it is used to check whether a delivery choice code (`dchs_cd`) is valid — by creating a finder with key `"0"` (the "not allowed" marker) and filtering through a resolved list of delivery codes, the system can reject records that should not proceed. The Javadoc (マップ判定 — "map evaluation") describes this as performing a determination of whether the value for a key matches.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["evaluate(item: HashMap<String, String>)"])
    START --> GET["itemValue = item.get(key)"]
    GET --> LOOP["for each value in values"]
    LOOP --> CHECK{"value.equals(itemValue)"}
    CHECK -->|true| RET_TRUE(["return true — match found"])
    CHECK -->|false| LOOP
    LOOP --> EMPTY(["values exhausted — no match"])
    EMPTY --> RET_FALSE(["return false — no match"])
    RET_TRUE --> END(["End"])
    RET_FALSE --> END
```

**Constant Resolution:**

This method does not directly branch on domain constants. Instead, it receives two fields from its constructor (`ListMultiFilter(String key, Object[] values)`):
- `key`: A string key identifying which entry in the map to examine (e.g., `"dchs_cd"`)
- `values`: An array of `Object` values representing the set of allowed or excluded values (e.g., `["0"]` for "not allowed")

The actual business meaning of the key and values is determined by the caller at construction time. For instance, in the calling context within `JKKWribSvcKeiOperateCC`:

```java
CAANMsgFinder ngFinder = new CAANMsgFinder(EKK1351C011CBSMsg1List.HEIYO_KH, "0");
```

Here, the key is `HEIYO_KH` (併用可否判定キー — "concurrent use judgment key") and the value `"0"` represents the "not allowed" (併用不可) marker. The method checks whether any resolved delivery choice code matches this forbidden marker.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `item` | `HashMap<String, String>` | A map representing a data record to be evaluated. The map carries key-value pairs extracted from a business object (such as `CAANMsg` fields), where keys are field identifiers and values are string representations of domain codes (e.g., delivery choice codes, status flags). |

**Instance fields read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `key` | `String` | The map key to look up. Set at construction time. Identifies which field in the item map should be evaluated (e.g., `"dchs_cd"` for delivery choice code). |
| `values` | `Object[]` | The set of allowed (or disallowed) values to match against. Set at construction time. Represents a list of valid domain codes for the given key. |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

This method performs **no database, SC (Service Component), CBS, or external service calls**. It is a pure in-memory predicate evaluation that:
- Reads from the input `HashMap` via `item.get(key)` (in-memory map lookup)
- Iterates over the local `Object[] values` array
- Performs value equality checks via `Object.equals()`

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `item.get(key)` | — | — | In-memory map lookup — retrieves the value for the configured key from the input item map |
| R | `value.equals(itemValue)` | — | — | Java object equality check — compares each allowed value against the item's value |

**Note:** While this method itself performs no CRUD operations, it is **called by** `Items.exist()`, `Items.find()`, and `Items.select()`, which in turn perform CRUD operations on the underlying collections or database views. The terminal operations from the callers are:
- `Items.exist` — Read/check existence in a collection of business objects
- `Items.find` — Read/find matching items from a collection
- `Items.select` — Read/select items from a collection based on predicate

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 131 methods.
Terminal operations from this method: `isAllEmptyTarget` [-], `isAllEmptyTarget` [-], `isCollect` [-], `isCollect` [-], `isCollect` [-], `isCollect` [-], `isCollect` [-], `isCollect` [-], `isCollect` [-], `isCollect` [-], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R]

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Caller: `Items.exist()` | `Items.exist(list, predicate)` -> `predicate.evaluate(item)` (via `Predicater.evaluate`) | Collection-level predicate evaluation — no terminal CRUD from this method |
| 2 | Caller: `Items.find()` | `Items.find(list, predicate)` -> `predicate.evaluate(item)` (via `Predicater.evaluate`) | Collection-level predicate evaluation — no terminal CRUD from this method |
| 3 | Caller: `Items.select()` | `Items.select(list, predicate)` -> `predicate.evaluate(item)` (via `Predicater.evaluate`) | Collection-level predicate evaluation — no terminal CRUD from this method |
| 4 | Caller: `JFUMailSupportInterface.communication()` | Mail communication framework uses predicate-based filtering | Depends on calling context |
| 5 | Caller: `JFUXPathManager.getItem()` | XPath-based item extraction uses predicate for validation | Depends on calling context |
| 6 | Caller: `JFUXPathManager.getItemAsNodeList()` | XPath node list retrieval with predicate filtering | Depends on calling context |
| 7 | Caller: `JFUXPathManager.isElement()` | XPath element existence check using predicate | Depends on calling context |
| 8 | Caller: `JKKWribSvcKeiOperateCC` resolveDchsCdHeiyo caller | `resolveDchsCdHeiyo` -> `CAANMsgFinder` construction -> `Items.exist(resultList, ngFinder)` -> `evaluate()` | `isAllEmptyTarget`, `isCollect` — filtering of resolved delivery codes |
| 9 | Caller: `JKKWribSvcKeiOperateCC.determinant` caller | Determination methods construct `CAANMsgFinder` with domain-specific keys/values | Terminal: `getString` from `CAANMsg` data objects |

**Direct caller summary:** This method is called as a predicate callback from higher-level collection operations (`Items.exist/find/select`) and is also used indirectly via XPath managers and mail support interfaces. It is most frequently invoked in the `JKKWribSvcKeiOperateCC` context for validating delivery choice codes and other domain-specific field values.

## 6. Per-Branch Detail Blocks

**Block 1** — SET `(key lookup)` (L17413)

Retrieves the value for the configured key from the input map. This is the initial data extraction step.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object itemValue = item.get(key);` // Retrieves the value associated with the configured key from the input HashMap. Returns null if the key is not present. |

**Block 2** — FOR-EACH `(for each value in values)` (L17415)

Iterates over the pre-configured array of allowed/disallowed values. This is the core matching loop.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `for (Object value : values)` // Iterates through each allowed value in the values array |

**Block 2.1** — IF-ELSE `(value.equals(itemValue))` (L17416)

Compares the current allowed value against the item's value using Java's `Object.equals()`. This is the core equality check.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (value.equals(itemValue))` // Checks if the current allowed value matches the item's value. Handles null-safety: if itemValue is null, equals() returns false unless value is also null. |

**Block 2.1.1** — RETURN `(true branch)` (L17417)

A match was found — the item's value is one of the allowed values. Return `true` immediately, short-circuiting the loop.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true;` // Match confirmed — the item's key value exists in the allowed values set |

**Block 3** — RETURN `(false branch — loop exhausted)` (L17420)

After exhausting all values without finding a match, return `false`. This indicates the item's value is not in the allowed set.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false;` // No match found — the item's key value is not in the allowed values set |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ListMultiFilter` | Class | A predicate filter that evaluates whether a map entry's value matches any of multiple allowed values. Implements `Predicater<HashMap<String, String>>`. |
| `Predicater` | Interface | A functional interface representing a boolean-valued predicate function. Used for filtering and searching collections. |
| `CAANMsgFinder` | Class | A finder class that wraps `ListMultiFilter` functionality for `CAANMsg` objects. Extends `ListMultiFilter` to provide message-specific predicate evaluation. |
| `key` | Field | The map key to evaluate. Configured at construction time. Identifies which field in the data map should be checked (e.g., `"dchs_cd"`). |
| `values` | Field | Array of allowed/disallowed values configured at construction. The method checks if the map's value matches any entry in this array. |
| `Items.exist()` | Method | Collection utility that checks if any element in a list satisfies a predicate. Used to find if at least one matching record exists. |
| `Items.find()` | Method | Collection utility that finds and returns elements matching a predicate. Used to retrieve matching records from a list. |
| `Items.select()` | Method | Collection utility that selects elements matching a predicate into a new list. Used to filter a collection by the predicate. |
| `HEIYO_KH` | Constant | "Heiyo Kanpo Key" — a field identifier used in `EKK1351C011CBSMsg1List` for concurrent use judgment. "Heiyo" (併用) means concurrent/multiple use, "Kanpo" (可否) means whether allowed or not. |
| `dchs_cd` | Field | Delivery Choice Code — identifies the delivery method for service equipment or installation (e.g., in-person, postal delivery). |
| `CAANMsg` | Class | A message/container class for business data objects in the Fujitsu Futurity BP framework. Represents a message-like data structure used in CBS communication. |
| `Predicater.evaluate()` | Method | The core predicate evaluation method. Implemented by `ListMultiFilter` as `evaluate(HashMap<String, String>)`. Returns true if the map's key-value pair matches allowed values. |
| `Object.equals()` | Method | Standard Java equality comparison. Used to compare the map's value against each allowed value. Handles null gracefully (null equals null is true). |
