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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.WribSvcHeiyoFilter` |
| Layer | CC/Common Component (Inner class within `JKKWribSvcKeiOperateCC` — service-level common utility) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### WribSvcHeiyoFilter.evaluate()

This method implements the `Predicater<HashMap<String, String>>` contract and serves as a **multi-value key-match filter**. It determines whether the value associated with a specific key in the given `item` map matches **any** entry in a pre-configured set of accepted values. The `key` and `values` fields are injected at construction time via the constructor, making this class a reusable predicate that filters a collection by checking whether each element's value at a specific key falls within an approved list.

In business terms, this filter is used during **service contract selection** (WribSvc — 引受サービス / underwriting service) to narrow down candidate service records based on criteria such as service code, distribution code, or status. The caller populates the `values` array with allowed values (e.g., valid service category codes) and specifies the key (e.g., `"wrib_svc_cd"`) to inspect on each candidate item.

The method implements the **predicate design pattern** — it accepts one input (`item`), evaluates a condition, and returns a boolean. It is used as part of an `Items.exist()` / `Items.select()` filtering pipeline, where each candidate item is tested against multiple such filters before being accepted or rejected.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["evaluate(item)"])
    STEP1["Retrieve itemValue = item.get(key)"]
    STEP2["Iterate over each value in values[]"]
    COND{"value.equals(itemValue)?"}
    BRANCH["Match found → return true"]
    EXIT["No match → return false"]

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> COND
    COND -- true --> BRANCH
    BRANCH --> EXIT
    COND -- false --> STEP2
    STEP2 --> EXIT
```

**Processing steps:**

1. **Retrieve value from map** — The method looks up the value associated with the pre-configured `key` field in the input `item` HashMap. The result is stored as an `Object` to allow comparison against any type in the `values` array.
2. **Iterate over allowed values** — The method loops through each entry in the pre-configured `values` array (populated at construction time).
3. **Equality check** — For each candidate value, it calls `Object.equals()` against the retrieved `itemValue`. This performs a shallow equality comparison (uses `String.equals()` when values are strings).
4. **Return on first match** — If any value matches, the method immediately returns `true`, short-circuiting the loop.
5. **Return false if exhausted** — If the loop completes without finding a match, the method returns `false`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `item` | `HashMap<String, String>` | A single candidate record represented as a key-value map. Each key is a field name (e.g., `"wrib_svc_cd"`, `"dchs_cd"`, `"svc_kei_no"`) and each value is the field's string representation. This is one element from a collection being filtered (e.g., one row of potential service records returned from a search query). |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `key` | `String` | The map key to inspect on each item. Configured at construction time — e.g., `"wrib_svc_cd"` (underwriting service code) or `"dchs_cd"` (distribution code). |
| `values` | `Object[]` | Array of accepted values for the configured `key`. Configured at construction time — e.g., `["1", "2"]` representing valid service categories. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `item.get(key)` | — | — | Reads the value for a specific key from the input HashMap. No DB access — in-memory map lookup. |
| R | `values[i]` (iterator) | — | — | Iterates over the pre-configured values array. No DB access — in-memory array iteration. |
| R | `value.equals(itemValue)` | — | — | Calls `Object.equals()` on each candidate value. Shallow equality comparison. No DB access. |

This method performs **no database or SC/CBS calls**. It operates entirely on in-memory data structures (`HashMap` and `Object[]`). It is a pure predicate/filter utility method.

## 5. Dependency Trace

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

**Direct callers (131 methods):**

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Caller: `Items.exist()` | `Items.exist(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |
| 2 | Caller: `Items.find()` | `Items.find(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |
| 3 | Caller: `Items.select()` | `Items.select(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |
| 4 | Caller: `JFUMailSupportInterface.communication()` | `communication(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |
| 5 | Caller: `JFUXPathManager.getItem()` | `getItem(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |
| 6 | Caller: `JFUXPathManager.getItemAsNodeList()` | `getItemAsNodeList(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |
| 7 | Caller: `JFUXPathManager.isElement()` | `isElement(filter)` -> `filter.evaluate(item)` | — (in-memory predicate evaluation) |

**Usage pattern:** This filter is typically composed with other filters (e.g., `DchsHeiyoFilter` for distribution code filtering) and passed to collection utility methods like `Items.exist()`, `Items.find()`, or `Items.select()` to filter lists of `HashMap` records during service underwriting (WribSvc) processing. No screen or batch entry points route through this method — it is a shared low-level predicate utility.

## 6. Per-Branch Detail Blocks

**Block 1** — [METHOD ENTRY] `(evaluate(HashMap<String, String> item))` (L17414)

> Retrieve the target value from the input map using the configured key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object itemValue = item.get(key);` // Retrieve value for the configured key from the input HashMap |

**Block 2** — [FOR-EACH LOOP] `(for (Object value : values))` (L17416)

> Iterate over each allowed value configured in the constructor. This is the filtering loop — each candidate value is tested against the item's value.

| # | Type | Code |
|---|------|------|
| 1 | SET | `value` ← loop variable assigned from `values[]` array |

**Block 2.1** — [IF CONDITION] `(value.equals(itemValue))` (L17417)

> Check if the current candidate value matches the item's value. Uses `Object.equals()` for shallow equality comparison. When both objects are `String` instances (which is the common case given `HashMap<String, String>`), this delegates to `String.equals()`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `value.equals(itemValue)` // Shallow equality comparison |
| 2 | RETURN | `return true;` // Match found — item passes the filter |

**Block 3** — [METHOD EXIT] `(end of loop)` (L17421)

> Loop exhausted without finding a matching value. The item does not pass the filter criteria.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false;` // No match — item fails the filter |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `evaluate` | Method | Predicate evaluation method — determines whether a given item satisfies the filter's acceptance criteria |
| `item` | Parameter | A single candidate record as a HashMap of field names to string values |
| `key` | Field | The HashMap key (field name) to inspect on each item — e.g., `"wrib_svc_cd"` |
| `values` | Field | Array of accepted values for the configured key — e.g., valid underwriting service codes |
| WribSvc | Business term | **Underwriting Service** (引受サービス) — Fujitsu's service selection/validation module that determines whether a service request can be accepted based on configuration rules |
| Predicater | Interface | Functional interface representing a boolean-valued predicate on one argument — the method under documents implements this contract |
| Items | Utility class | Collection filtering utility that applies predicates to lists of items (used by `exist`, `find`, `select`) |
| ListMultiFilter | Class name | A filter that accepts an item if its value at a specific key matches **any** of multiple configured values (OR logic across allowed values) |
| `DchsHeiyoFilter` | Class name | Distribution code eligibility filter — similar predicate but for `CAANMsg` objects, checking distribution code acceptance |
| `CAANMsg` | Class name | Message wrapper for database records — provides `getString()` accessor methods |
| `JKKWribSvcKeiOperateCC` | Class name | Main service component controller for underwriting service key processing (引受サービスKey操作) |
