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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.SvcKeiFinderWithTrgtSvc` |
| Layer | CC/Common Component — inner class `ListMultiFilter` within `JKKWribSvcKeiOperateCC` |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### SvcKeiFinderWithTrgtSvc.evaluate()

This method implements a **multi-value containment check** for map-based service type filtering. It is the core predicate logic of the `ListMultiFilter` inner class, which implements the `Predicater<HashMap<String, String>>` interface. The method's business purpose is to determine whether a given item (represented as a `HashMap<String, String>`) matches any of a predefined set of acceptable values for a specific key. The `key` field identifies the map entry (typically a service-type classification code such as `svc_kei_cd`, `dchs_cd`, or similar domain fields), and the `values` field holds an array of allowed codes. This enables callers to filter collections of items by membership against multiple permitted codes in a single pass — for example, selecting only order records whose service type matches any code in a list of active service categories. The method follows the **Predicate design pattern**, serving as a reusable filter function that can be composed with collection operations like `Items.exist()`, `Items.find()`, and `Items.select()` (pre-computed callers from the code graph). It acts as a shared utility called by many screen and business logic layers to perform multi-value membership tests against service-type classification maps.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["evaluate(item)"])
    ITEM_GET["itemValue = item.get(key)"]
    COMPARE{"value.equals(itemValue)?"}
    RETURN_TRUE["return true"]
    RETURN_FALSE["return false"]
    END_NODE(["Return"])

    START --> ITEM_GET
    ITEM_GET --> COMPARE
    COMPARE -->|Match found| RETURN_TRUE
    RETURN_TRUE --> END_NODE
    COMPARE -->|No match, continue| COMPARE
    COMPARE -->|All checked| RETURN_FALSE
    RETURN_FALSE --> END_NODE
```

**Step-by-step:**

1. **Retrieve value from map** — The method fetches the value associated with the `key` field from the input `item` HashMap. This retrieves the actual service-type classification code stored in the item being evaluated.

2. **Iterate over allowed values** — The method loops through each element in the `values` object array, which was set during `ListMultiFilter` construction via its constructor `ListMultiFilter(String key, Object[] values)`.

3. **Equality comparison** — For each element in `values`, the method checks if `value.equals(itemValue)`. If any element matches the item's retrieved value, the method returns `true` immediately (short-circuit evaluation).

4. **No match fallback** — If the loop exhausts all elements without finding a match, the method returns `false`.

No database reads or SC (Service Component) calls are made — this is a pure in-memory containment check.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `item` | `HashMap<String, String>` | A map representing a single data record or item, keyed by field names (e.g., service classification codes). The map's key is pre-configured via the `ListMultiFilter` constructor and identifies which field within the map to check. The values array is also pre-configured and represents the set of acceptable codes for that field. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `key` | `String` | The map entry key to look up (e.g., a service-type classification code field name) |
| `values` | `Object[]` | An array of accepted values for the given key; the method checks if the item's value at `key` is a member of this set |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `item.get` | - | - | Reads a value from the input HashMap by key — in-memory data access |
| R | `Values.equals()` | - | - | Compares each value in the array against the retrieved item value — no external I/O |

**Analysis:** This method performs **zero** external CRUD operations. It is a pure in-memory predicate that checks whether a map value is contained in a predefined array. There are no SC calls, no database reads, no entity access, and no HTTP or remote calls. It is a lightweight, stateless containment check.

## 5. Dependency Trace

### Callers (Pre-computed from code graph)

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `Items.exist()` | `Items.exist(Predicate)` -> `ListMultiFilter.evaluate` | `evaluate [R] in-memory HashMap` |
| 2 | `Items.find()` | `Items.find(Predicate)` -> `ListMultiFilter.evaluate` | `evaluate [R] in-memory HashMap` |
| 3 | `Items.select()` | `Items.select(Predicate)` -> `ListMultiFilter.evaluate` | `evaluate [R] in-memory HashMap` |
| 4 | `JFUMailSupportInterface.communication()` | `communication()` -> uses `Predicater<HashMap<String, String>>` -> `evaluate` | `evaluate [R] in-memory HashMap` |
| 5 | `JFUXPathManager.getItem()` | `getItem()` -> uses `Predicater<HashMap<String, String>>` -> `evaluate` | `evaluate [R] in-memory HashMap` |
| 6 | `JFUXPathManager.getItemAsNodeList()` | `getItemAsNodeList()` -> uses `Predicater<HashMap<String, String>>` -> `evaluate` | `evaluate [R] in-memory HashMap` |
| 7 | `JFUXPathManager.isElement()` | `isElement()` -> uses `Predicater<HashMap<String, String>>` -> `evaluate` | `evaluate [R] in-memory HashMap` |

**Pre-computed callers:** `Items.exist()`, `Items.find()`, `Items.select()`, `JFUMailSupportInterface.communication()`, `JFUXPathManager.getItem()`, `JFUXPathManager.getItemAsNodeList()`, `JFUXPathManager.isElement()`

### Called methods (terminal operations)

`isAllEmptyTarget`, `isCollect`, `getString` — these are not direct calls from `evaluate` itself but are terminal operations from the method's call graph context.

## 6. Per-Branch Detail Blocks

**Block 1** — IF-STYLE CONTAINMENT CHECK `values[i].equals(itemValue)` (L17412)

> Retrieves the value from the map for the configured key and checks if it is present in the `values` array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object itemValue = item.get(key);` // Retrieve the map value for the configured key field |
| 2 | SET | `values` = `Object[]` // Pre-configured array of accepted values (set via constructor) [-> constructed with key + allowed codes] |

**Block 1.1** — FOR-EACH LOOP over `values` (L17414-17416)

> Iterates through each accepted value to find a match.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `for (Object value : values)` // Iterate over each allowed code/value |
| 2 | EXEC | `if (value.equals(itemValue))` // Compare current array element against the item's map value |
| 3 | RETURN | `return true;` // Match found — item's value is contained in the allowed set |

**Block 1.1.1** — ELSE FALLBACK (no match found in loop) (L17417)

> All values have been checked without a match.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false;` // No accepted value matched — item is not in the set |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `Predicater<T>` | Interface | A functional interface defining a single-argument predicate (`evaluate(T)`) used for filtering collections |
| `ListMultiFilter` | Class | An inner class implementing `Predicater<HashMap<String, String>>` that checks if a map's value at a specific key is in a set of allowed values |
| `key` | Field | The map entry key used to look up a value from the input HashMap |
| `values` | Field | Array of accepted values for the key — the method tests membership of the item's value in this set |
| `item` | Parameter | A HashMap representing a single record, typically containing service-type classification codes and related fields |
| `itemValue` | Local variable | The value retrieved from `item` at the configured `key` position |
| `evaluate` | Method | Predicate method that returns `true` if the item's value matches any of the allowed values in the `values` array |
| `Items` | Class | Collection utility class providing `exist`, `find`, `select` methods that accept `Predicater` instances for filtering |
| `JFUXPathManager` | Class | XPath query manager that provides `getItem`, `getItemAsNodeList`, and `isElement` methods accepting predicates |
| `JFUMailSupportInterface` | Class | Mail support interface class that uses predicates in its `communication` method |
| `CD00037` | Constant | Value of `CD_TYP_SVC_KEI_STAT` — service type status classification code (from `JKKAdchgInitDspConstCC`) |
| `CD00345` | Constant | Value of `CD_TYP_NYUKYO_FLR_CNT` — entry floor count classification code |
| `CD01234` | Constant | Value of `CD_TYP_BMP_KOJI_TIME` — BMP construction time classification code |
| `CD00212` | Constant | Value of `CD_TYP_KKTK_SBT` — contract sub-type classification code |
| `Predicater<HashMap<String, String>>` | Type | Predicate interface parameterized for HashMap items — used as filter type throughout the system |
| `CAANMsg` | Class | Message wrapper class used in the related `evaluate(CAANMsg)` overload for data extraction item compatibility checks |
| `dchs_cd` | Field | Delivery/change code field within `CAANMsg` items — used in the related overloaded `evaluate` method |
| `resolveDchsCdHeiyo` | Method | Resolves delivery change code conflicts — called by the `evaluate(CAANMsg)` overload in the parent `JKKWribSvcKeiOperateCC` class |
| `Items.exist` | Method | Checks if any item in a collection matches a given predicate |
| `Items.find` | Method | Finds items in a collection matching a given predicate |
| `Items.select` | Method | Selects/filter items from a collection matching a given predicate |
