# Business Logic — KKW00816SFBean.removeElementFromListData() [25 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00816SF.KKW00816SFBean` |
| Layer | Common Component / View Bean (UI data-layer utility) |
| Module | `KKW00816SF` (Package: `eo.web.webview.KKW00816SF`) |

## 1. Role

### KKW00816SFBean.removeElementFromListData()

This method is the central list-item removal dispatcher for the KKW00816SF service contract management screen. It removes a single entry at a given zero-based index from typed list data structures that are bound to UI display components. The method acts as a **routing/dispatch** utility: it inspects the incoming `key` parameter to determine which internal list field should be modified, then delegates removal to the appropriate data collection.

Three distinct removal targets are handled: (1) when the key starts with `"//"` the method delegates to the superclass (`KKW00816SFBean.super.removeElementFromListData`), which handles common information screen lists. (2) When the key equals `"顧客契約引継リスト"` (Customer Contract Succession List, item ID: `cust_kei_hktgi_list`), it removes an entry from the `cust_kei_hktgi_list_list` — a list of customer contract succession line items used in the service contract screen. (3) When the key equals `"オプションサービス契約リスト"` (Option Service Contract List, item ID: `op_svc_kei_list`), it removes an entry from the `op_svc_kei_list_list` — a list of optional service contract line items.

In the larger system, this method serves as the shared list-mutation entry point for all screen flows that manage customer contracts and option services. It is the `D` (Delete) half of the CRUD cycle for list data, complementing the add-and-modify operations performed by other methods such as `KKW00816SF01DBean.removeElementFromListData()` (which handles the subordinate "disaster reason code" list for the SF01 detail flow).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["removeElementFromListData key, index"])
    COND_NULL["key != null?"]
    COMMON["RemoveElementFromListData super key, index"]
    END1(["END — null key: no-op"])

    COND_CUSTOMER["key equals 顧客契約引継リスト?"]
    BOUNDS1["index >= 0 && index < cust_kei_hktgi_list_list.size()"]
    REMOVE1["cust_kei_hktgi_list_list.remove index"]
    END2(["END"])

    COND_OPTION["key equals オプションサービス契約リスト?"]
    BOUNDS2["index >= 0 && index < op_svc_kei_list_list.size()"]
    REMOVE2["op_svc_kei_list_list.remove index"]
    END3(["END"])

    START --> COND_NULL
    COND_NULL -->|true| COMMON
    COND_NULL -->|false| END1
    COMMON --> COND_CUSTOMER
    COND_CUSTOMER -->|true| BOUNDS1
    COND_CUSTOMER -->|false| COND_OPTION
    BOUNDS1 -->|true| REMOVE1
    BOUNDS1 -->|false| END2
    REMOVE1 --> END2
    COND_OPTION -->|true| BOUNDS2
    COND_OPTION -->|false| END3
    BOUNDS2 -->|true| REMOVE2
    BOUNDS2 -->|false| END3
    REMOVE2 --> END3
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The list identifier (item name) that determines which internal list to modify. Can be `"//"` prefix strings (common information screen lists, delegated to base class), `"顧客契約引継リスト"` (Customer Contract Succession List — the key that selects the customer contract line-item list), or `"オプションサービス契約リスト"` (Option Service Contract List — the key that selects the optional service contract line-item list). A `null` value results in a no-op (no removal performed). |
| 2 | `index` | `int` | The zero-based position of the entry to remove within the target list. Must satisfy `0 <= index < list.size()` to actually perform the removal; out-of-range values cause a safe no-op (the `if` guard prevents `IndexOutOfBoundsException`). |

**External state read:**

| No | Field | Type | Business Description |
|----|-------|------|---------------------|
| 1 | `cust_kei_hktgi_list_list` | `X33VDataTypeList` | Customer contract succession list — holds line-item objects for the customer contract succession data type. Each element is a `X33VDataTypeBeanInterface` that can load data by item name (`顧客契約引継リスト`) and key (`value`). |
| 2 | `op_svc_kei_list_list` | `X33VDataTypeList` | Option service contract list — holds line-item objects for optional service contract data type. Each element is a `X33VDataTypeBeanInterface` that can load data by item name (`オプションサービス契約リスト`) and key (`value`). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| D | `KKW00816SFBean.removeElementFromListData` | KKW00816SFBean | - | Calls `removeElementFromListData` in `KKW00816SFBean` |

### Inferred from method analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| D | `KKW00816SFBean.removeElementFromListData(String, int)` | KKW00816SFBean | `cust_kei_hktgi_list_list` (in-memory list data) | In-memory list deletion — removes the element at `index` from the customer contract succession list. |
| D | `KKW00816SFBean.removeElementFromListData(String, int)` | KKW00816SFBean | `op_svc_kei_list_list` (in-memory list data) | In-memory list deletion — removes the element at `index` from the option service contract list. |

**Note:** This method performs **in-memory list mutations only** — it does not directly execute database operations or invoke SC/CBS components. The actual persistence of removed items is handled upstream by the screen controller (e.g., `KKW00816SF01DBean`) which manages the data flow through service components and DAO layers. The `super.removeElementFromListData()` delegation may cascade into shared framework list operations in the common view bean base class.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class:KKW00816SFBean (self-delegation) | `KKW00816SFBean.removeElementFromListData` (self-call or framework dispatch) | `removeElementFromListData [D] cust_kei_hktgi_list_list / op_svc_kei_list_list` |
| 2 | Screen:KKW00816SF01 (via base class) | `KKW00816SF01DBean.removeElementFromListData` -> `super.removeElementFromListData` -> `KKW00816SFBean.removeElementFromListData` | `removeElementFromListData [D] ido_rsn_cd_list` |

**Notes on callers:**
- The method is called both directly (within the same class or by framework) and indirectly through the superclass delegation path (`super.removeElementFromListData`).
- `KKW00816SF01DBean` overrides this method for its own list (`ido_rsn_cd_list` / 異動理由コード) and does not call the parent implementation.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(key != null)` (L2404)

> Guards against `null` key. If `key` is `null`, the method returns immediately (no-op).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.removeElementFromListData(key, index)` // Delegate to superclass (common information screen list handling) — key starts with "//" |

**Block 1.1** — ELSE-IF `(key.equals("顧客契約引継リスト"))` [顧客契約引継リスト = "顧客契約引継リスト"] (L2411)

> Branch for the Customer Contract Succession List (item ID: `cust_kei_hktgi_list`). This is the primary data type for the service contract screen (KKW00816SF01).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `cust_kei_hktgi_list_list.remove(index)` // Guarded deletion — removes the element at index from the customer contract succession list |

**Block 1.1.1** — IF `(index >= 0 && index < cust_kei_hktgi_list_list.size())` (L2411)

> Bounds check. Only performs removal if the index falls within the valid range of the customer contract succession list. Prevents `IndexOutOfBoundsException`.

| # | Type | Code |
|---|------|------|
| 1 | SET | Guard condition | `index >= 0 && index < cust_kei_hktgi_list_list.size()` |
| 2 | EXEC | `cust_kei_hktgi_list_list.remove(index)` // Delete element at specified index |

**Block 1.2** — ELSE-IF `(key.equals("オプションサービス契約リスト"))` [オプションサービス契約リスト = "オプションサービス契約リスト"] (L2417)

> Branch for the Option Service Contract List (item ID: `op_svc_kei_list`). Handles removal from the optional service contract line-item list used in the service contract screen.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `op_svc_kei_list_list.remove(index)` // Guarded deletion — removes the element at index from the option service contract list |

**Block 1.2.1** — IF `(index >= 0 && index < op_svc_kei_list_list.size())` (L2417)

> Bounds check for the option service contract list. Only performs removal if the index is within valid range.

| # | Type | Code |
|---|------|------|
| 1 | SET | Guard condition | `index >= 0 && index < op_svc_kei_list_list.size()` |
| 2 | EXEC | `op_svc_kei_list_list.remove(index)` // Delete element at specified index |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `cust_kei_hktgi_list_list` | Field | Customer Contract Succession List — in-memory data structure holding line-item objects for customer contract succession data on the service contract screen |
| `op_svc_kei_list_list` | Field | Option Service Contract List — in-memory data structure holding line-item objects for optional service contracts on the service contract screen |
| `cust_kei_hktgi_list` | Field | Customer Contract Succession List (item ID) — internal identifier used to load/save data by the view data type system |
| `op_svc_kei_list` | Field | Option Service Contract List (item ID) — internal identifier used to load/save data by the view data type system |
| `X33VDataTypeList` | Type | View data type list — a framework collection that holds objects implementing `X33VDataTypeBeanInterface`, used for UI-bound list data |
| `X33VDataTypeBeanInterface` | Type | Interface for view data type beans — provides `loadModelData(itemName, key)` for reading field values from list elements |
| `ido_rsn_cd_list` | Field | Disaster reason code list — holds reason codes for customer contract changes (used in KKW00816SF01DBean variant) |
| 顧客契約引継リスト | Field | Customer Contract Succession List — Japanese item name for the customer contract succession data type |
| オプションサービス契約リスト | Field | Option Service Contract List — Japanese item name for the optional service contract data type |
| 異動理由コード | Field | Disaster/Change Reason Code — reason code for contract modifications (used in SF01DBean) |
| KKW00816SF | Module | Service Contract Management screen module — handles service contract creation and management |
| KKW00816SF01DBean | Class | Detail view bean for SF01 screen — handles the detail data flow for customer contract succession with disaster reason codes |
| X33SException | Type | Framework exception class — thrown by bean methods on business or system errors |
| Super class delegation | Pattern | When `key` starts with "//", removal is delegated to the base class handler for common information screen lists |
