# Business Logic — KKW01021SF01DBean.clearListDataInstance() [10 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW01021SF.KKW01021SF01DBean` |
| Layer | View / Data Bean (webview package — displays data on UI screens) |
| Module | `KKW01021SF` (Package: `eo.web.webview.KKW01021SF`) |

## 1. Role

### KKW01021SF01DBean.clearListDataInstance()

This method is a list-data maintenance utility within the data bean layer of the KKW01021SF screen module. Its business purpose is to clear (reset) the elements of a specific list data field on demand, identified by a human-readable item name string (`key`). In the K-Opticom application framework, screen data beans maintain mutable list collections that hold row-level display data; when a screen needs to reset part of its state — for example, during re-fetch, screen transitions, or form resets — this method is called to wipe the contents of the targeted list. It implements the **delegation pattern** common across the bean hierarchy: subclasses override this method to clear module-specific lists while the parent (KKW01021SFBean) handles shared/common information lists via `super`. In this subclass (KKW01021SF01DBean), the method specifically handles the "Movement Reason Code" list (`ido_rsn_cd_list`), which tracks the reasons for service contract changes or transfers. The method has a single conditional branch: if the `key` parameter exactly matches the Japanese string "異動理由コード" (Movement Reason Code), it calls `.clear()` on the `ido_rsn_cd_list` collection, erasing all stored reason codes. This is a write-side (U/D) operation that mutates local in-memory state without touching the database.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["clearListDataInstance(key)"])
    CHECK_NULL{"key != null?"}
    CLEAR_LIST["ido_rsn_cd_list.clear()"]
    RETURN(["Return / Next"])

    START --> CHECK_NULL
    CHECK_NULL --> |false| RETURN
    CHECK_NULL --> |true| CHECK_KEY{"key equals \"異動理由コード\""}
    CHECK_KEY --> |false| RETURN
    CHECK_KEY --> |true| CLEAR_LIST
    CLEAR_LIST --> RETURN
```

This flowchart shows the two-level conditional dispatch:

1. **Null guard** — If `key` is `null`, the method returns immediately without any side effect (safe no-op).
2. **Key dispatch** — If `key` is non-null, it checks whether the key matches the Japanese label "異動理由コード" (Movement Reason Code). Only an exact string match triggers the clear operation on `ido_rsn_cd_list`. Any other key value results in a no-op return.

**Constant Resolution:** The condition `key.equals("異動理由コード")` uses a hardcoded Japanese string literal (no external constant class reference found). This string is the display name / project item label for the "異動理由コード" field (item ID: `ido_rsn_cd`), as documented in the source comment.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The human-readable item name (display label) of the list to clear. This string identifies which list data field the caller wants to reset. For this method, it must exactly match `"異動理由コード"` (Movement Reason Code) to have any effect. If `null`, the method performs no operation. |

**Instance fields / external state read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | Movement Reason Code list — holds the list of reason codes for service contract changes/transfers. Each element is a `X33VDataTypeStringBean` containing a reason code string. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| D | `X33VDataTypeList.clear` | - | `ido_rsn_cd_list` (in-memory) | Clears all elements from the in-memory movement reason code list. No database access; this is a local state reset. |

**Classification rationale:** The only operation performed is `.clear()` on a `X33VDataTypeList` instance, which removes all elements from the collection. This is a Delete (D) operation on in-memory data, not a database operation. No SC/CBS layer is invoked, and no Entity or database table is accessed.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW01021SF | `KKW01021SFBean.clearListDataInstance` -> `KKW01021SF01DBean.clearListDataInstance` | `ido_rsn_cd_list.clear()` [D] (in-memory) |
| 2 | (Inherited via super call) | `KKW01021SFBean.clearListDataInstance(key)` -> `super.clearListDataInstance(key)` -> parent framework method | - |

**Notes on dependency chain:**
- The primary caller within the KKW01021SF module is the parent bean `KKW01021SFBean`, which overrides `clearListDataInstance` and delegates to `super.clearListDataInstance(key)` for common information list items. The subclass implementation (KKW01021SF01DBean) is the leaf method in this hierarchy.
- A large number of other screen beans in the FUW (runtime/web) packages also define `clearListDataInstance` and call `super.clearListDataInstance(key)`, but they are **not** callers of this specific method — they are sibling implementations in the same bean framework pattern.
- No CBS, SC, or batch component calls this method directly; it is invoked through the bean layer by screen processing logic.

## 6. Per-Branch Detail Blocks

**Block 1** — `[IF]` `(key != null)` (L657)

> Null guard: ensures the method does not throw NullPointerException if `key` is `null`. If `key` is `null`, control skips the entire inner block and returns.

| # | Type | Code |
|---|------|------|
| 1 | SET | — (no local variable assignment) |
| 2 | COND | `if(key != null)` — null check on the key parameter |
| 3 | CALL | Enters inner conditional block |

**Block 1.1** — `[IF]` `(key.equals("異動理由コード"))` `[異動理由コード="異動理由コード"]` (L659–660)

> Branch condition: checks whether the `key` parameter matches the Japanese display label "異動理由コード" (Movement Reason Code). This label is the project item name used to identify the movement reason code list. If matched, the list is cleared. If not matched, the method returns without effect.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("異動理由コード")` — string comparison with hardcoded display name (項目ID: `ido_rsn_cd`) |
| 2 | CALL | `ido_rsn_cd_list.clear()` — clears all elements from the movement reason code list instance |

**Block 1.1.1** — `[ELSE branch of inner IF]` (implicit, no else block)

> If `key` does not equal "異動理由コード", the method falls through the outer `if` block and returns normally. No operation is performed.

**Block 2** — `[ELSE branch of outer IF]` `(key == null)` (implicit, no else block)

> If `key` is `null`, the method returns immediately without any side effect. This is a safe-guard that prevents `NullPointerException` on the subsequent `key.equals(...)` call.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` — implicit; method ends with no operation |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ido_rsn_cd` | Field | Movement Reason Code — the reason code for a service contract change or transfer (異動理由コード). Stored as strings within the `ido_rsn_cd_list` collection. |
| `異動理由コード` | Japanese label | Movement Reason Code — the display name / project item label (項目名) for the movement reason code field on the screen. Used as the key to identify this list. |
| `ido_rsn_cd_list` | Field | Movement Reason Code List — an `X33VDataTypeList` instance holding the list of movement reason codes for the current screen context. Each element is a `X33VDataTypeStringBean` containing a reason code value. |
| `cust_kei_hktgi_list` | Field | Customer Contract List — the list data field for customer contract lines, handled by the parent bean class (KKW01021SFBean), not by this subclass. |
| `X33VDataTypeList` | Type | Framework list data type — a generic typed list collection used in the K-Opticom web framework to hold UI display data for screen beans. |
| `X33VDataTypeStringBean` | Type | Framework string data wrapper — a value holder for string-type display data within an `X33VDataTypeList`. |
| `DBean` | Acronym | Display Bean — a data bean class that manages the display data (input/output) for a specific screen. The "01" suffix (KKW01021SF01DBean) distinguishes it from the parent bean (KKW01021SFBean). |
| `KKW01021SF` | Screen code | Screen/module identifier — the screen handling movement/transfer reason code operations (異動理由コード処理). |
| `X33SException` | Type | Framework exception — the standard checked exception thrown by screen processing methods in the K-Opticom web framework. |
| `super.clearListDataInstance` | Pattern | Parent delegation — the pattern where the parent bean class handles common information list items (keys starting with "//") and delegates to it, while subclasses add their own specific list clear operations. |
