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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA16801SF.KKW02516SFBean` |
| Layer | Controller / Web View Bean (package: `eo.web.webview.KKA16801SF`) |
| Module | `KKA16801SF` (Package: `eo.web.webview.KKA16801SF`) |

## 1. Role

### KKW02516SFBean.removeElementFromListData()

This method provides item-level removal from structured UI list data within the service contract transfer screen (`KKA16801SF`). It is the designated handler for dynamically deleting individual rows from list-type form fields — specifically the **Customer Contract Inheritance List** (`顧客契約引継リスト`) and the **Movement Reason List** (`異動理由リスト`) — which are used during service contract line-item transfer and change operations in the telecom service management domain.

The method implements a **routing/dispatch pattern**: it inspects the `key` parameter to determine which internal list the caller intends to modify, then applies the removal operation to the corresponding data structure. When the key begins with `//`, it delegates to the superclass implementation (`super.removeElementFromListData`), which handles the **shared info view list** — a generic list infrastructure used across multiple screens in the platform.

This method's role in the larger system is as a **data-model mutation primitive** for the `X33VListedBeanInterface` contract. Any screen using the `KKA16801SF` module can invoke this method to remove an element from a named list, enabling dynamic add/remove row behavior on the UI without requiring a full screen re-render. It is part of the screen-state management layer, ensuring the backend bean's list data stays in sync with user actions on list-based form components.

The method handles three logical branches:
1. **Shared info view** (key starts with `//`) — delegates to the superclass.
2. **Customer contract inheritance list** (key equals `顧客契約引継リスト`) — removes from `cust_kei_hktgi_list_list`.
3. **Movement reason list** (key equals `異動理由リスト`) — removes from `ido_rsn_list_list`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["removeElementFromListData key, index"])
    CHECK_KEY_NULL{key != null}
    CHECK_SLASH{key starts with //}
    SUPER_CALL["super.removeElementFromListData"]
    CHECK_KEY_CUST{key equals customer contract list}
    CHECK_IDX_CUST{index in cust_kei_hktgi range}
    REMOVE_CUST["cust_kei_hktgi_list_list.remove index"]
    CHECK_KEY_IDO{key equals movement reason list}
    CHECK_IDX_IDO{index in ido_rsn range}
    REMOVE_IDO["ido_rsn_list_list.remove index"]
    END_NODE(["Return"])

    START --> CHECK_KEY_NULL
    CHECK_KEY_NULL -->|true| CHECK_SLASH
    CHECK_KEY_NULL -->|false| END_NODE
    CHECK_SLASH -->|true| SUPER_CALL
    SUPER_CALL --> END_NODE
    CHECK_SLASH -->|false| CHECK_KEY_CUST
    CHECK_KEY_CUST -->|true| CHECK_IDX_CUST
    CHECK_KEY_CUST -->|false| CHECK_KEY_IDO
    CHECK_KEY_IDO -->|true| CHECK_IDX_IDO
    CHECK_KEY_IDO -->|false| END_NODE
    CHECK_IDX_CUST -->|true| REMOVE_CUST
    CHECK_IDX_CUST -->|false| END_NODE
    REMOVE_CUST --> END_NODE
    CHECK_IDX_IDO -->|true| REMOVE_IDO
    CHECK_IDX_IDO -->|false| END_NODE
    REMOVE_IDO --> END_NODE
```

**Branch descriptions:**

| Branch | Condition | Action |
|--------|-----------|--------|
| Guard | `key == null` | Silently returns — no operation performed (defensive null handling) |
| Branch 1 | `key.startsWith("//")` | Delegates to `super.removeElementFromListData(key, index)` — shared info view list removal handled by base class |
| Branch 2 | `key.equals("顧客契約引継リスト")` AND index in range | Removes element at `index` from `cust_kei_hktgi_list_list` (Customer Contract Inheritance List) |
| Branch 3 | `key.equals("異動理由リスト")` AND index in range | Removes element at `index` from `ido_rsn_list_list` (Movement Reason List) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The list item name / identifier that determines which internal list the caller wants to remove an element from. It acts as a routing key. Possible values include `//` (prefix, for shared info view list — delegated to superclass), `"顧客契約引継リスト"` (Customer Contract Inheritance List — for service contract line-item transfer), and `"異動理由リスト"` (Movement Reason List — for service change/movement reason codes). If `null`, the method performs no operation. |
| 2 | `index` | `int` | The zero-based positional index of the element to remove from the target list. The method validates that `index` falls within the bounds of the target list before performing removal; out-of-range indices are silently ignored (no exception thrown). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `cust_kei_hktgi_list_list` | `X33VDataTypeList` | Customer contract inheritance list — holds the collection of service contract line items being transferred. Elements are removed from this list when the key matches `顧客契約引継リスト`. |
| `ido_rsn_list_list` | `X33VDataTypeList` | Movement reason list — holds the collection of reason codes for service changes/movements. Elements are removed from this list when the key matches `異動理由リスト`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| D | `super.removeElementFromListData` | (superclass: X33VViewBaseBean) | - | Calls `removeElementFromListData` via superclass — shared info view list removal. Entity/DB not directly accessible; handled by base class infrastructure. |
| D | `cust_kei_hktgi_list_list.remove(index)` | - | - | Removes element from in-memory `cust_kei_hktgi_list_list` (Customer Contract Inheritance List). Local data structure mutation, no DB interaction. |
| D | `ido_rsn_list_list.remove(index)` | - | - | Removes element from in-memory `ido_rsn_list_list` (Movement Reason List). Local data structure mutation, no DB interaction. |

**Classification rationale:**

All operations in this method are **D (Delete)** at the application data-model level. However, none of these operations perform database-level CRUD — they manipulate in-memory `X33VDataTypeList` collections that serve as the backing data for UI list components. The actual persistence of list modifications occurs elsewhere in the screen lifecycle (typically via a separate `execute` or `register` method that sends the modified bean state to a service component).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen: KKA16801SF (KKW02516SFBean) | `KKW02516SFBean.removeElementFromListData` | In-memory list mutation (D) |

**Caller context:**

The method is defined on `KKW02516SFBean` and is invoked from the screen controller (`KKA16801SF`) as part of its list data management. The primary callers are the `KKW02516SFBean` itself and its subclass `KKW02516SF01DBean`, which overrides the method to handle its own list types (`ido_rsn_cd_list`, `op_svc_kei_no_list`). The method is typically called from UI event handlers or JavaScript-driven screen actions when a user removes a row from a list-based form component.

Note: The pre-computed code graph indicates that `KKW02516SFBean.removeElementFromListData()` is the sole direct caller (self-referential), consistent with this being a screen bean method invoked by the screen's own event-dispatch logic rather than by other business components.

## 6. Per-Branch Detail Blocks

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

> Guard clause: validates that the key parameter is non-null before any processing. If `key` is null, the method silently returns without any operation. This is defensive programming to prevent NullPointerException.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if(key != null)` // Defensive null guard — skip all processing if key is null |

**Block 1.1** — [IF] `(key.startsWith("//"))` — Shared Info View Branch (L1967)

> When the key starts with `//`, this indicates the caller is requesting removal from a shared info view list. The method delegates this operation to the superclass (`X33VViewBaseBean.removeElementFromListData`), which manages a generic list infrastructure shared across multiple screens in the platform. The Japanese comment states: 「共通情報ビューンのリストの場合 — 共有情報ビューンは基底クラスで処理」 ("In the case of a shared info view list — shared info view is processed by the base class").

| # | Type | Code |
|---|------|------|
| 1 | SET | — |
| 2 | CALL | `super.removeElementFromListData(key, index)` // Delegate to superclass for shared info view list removal |

**Block 1.2** — [ELSE-IF] `(key.equals("顧客契約引継リスト"))` — Customer Contract Inheritance List Branch (L1971)

> The Japanese comment states: 「データタイプが KKW02516SF01 の繰り返し指定項目"顧客契約引継リスト"(項目ID:cust_kei_hktgi_list)」 ("Data type is KKW02516SF01's repeated specification item 'Customer Contract Inheritance List' (item ID: cust_kei_hktgi_list)"). This branch handles removal from the customer contract inheritance list used during service contract line-item transfer operations.

| # | Type | Code |
|---|------|------|
| 1 | SET | — |
| 2 | EXEC | `if(index >= 0 && index < cust_kei_hktgi_list_list.size())` // Validate index is within list bounds |
| 3 | CALL | `cust_kei_hktgi_list_list.remove(index)` // Remove the element at the specified index from the customer contract inheritance list |

**Block 1.2.1** — [ELSE-IF] `(key.equals("異動理由リスト"))` — Movement Reason List Branch (L1977)

> The Japanese comment states: 「データタイプが KKW02516SF02 の繰り返し指定項目"異動理由リスト"(項目ID:ido_rsn_list)」 ("Data type is KKW02516SF02's repeated specification item 'Movement Reason List' (item ID: ido_rsn_list)"). This branch handles removal from the movement reason list used during service change/movement operations to manage reason codes for service modifications.

| # | Type | Code |
|---|------|------|
| 1 | SET | — |
| 2 | EXEC | `if(index >= 0 && index < ido_rsn_list_list.size())` // Validate index is within list bounds |
| 3 | CALL | `ido_rsn_list_list.remove(index)` // Remove the element at the specified index from the movement reason list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `cust_kei_hktgi_list_list` | Field | Customer contract inheritance list — an in-memory `X33VDataTypeList` holding the collection of service contract line items (customer contract records) being transferred during a service line-item change operation. |
| `ido_rsn_list_list` | Field | Movement reason list — an in-memory `X33VDataTypeList` holding the collection of reason codes that describe why a service is being moved, changed, or modified. |
| 顧客契約引継リスト | Field (Japanese) | Customer Contract Inheritance List — the display name for the customer contract transfer list item. |
| 異動理由リスト | Field (Japanese) | Movement Reason List — the display name for the service change reason list item. |
| `X33VDataTypeList` | Class | A typed list data structure used by the X33V framework for managing UI-bound list data in view beans. |
| `X33VViewBaseBean` | Class | Base class for all X33V view beans, providing common list management infrastructure including the `removeElementFromListData` method that handles shared info view lists. |
| `X33VListedBeanInterface` | Interface | Contract interface that view beans must implement to support list-type form components (add/remove/clear list operations). |
| `//` (key prefix) | Constant | Special key prefix that identifies shared info view lists — lists managed by the base class infrastructure rather than individual screen beans. |
| KKA16801SF | Screen / Module | Service contract line-item transfer/change screen — the UI module that this bean belongs to. Handles operations for transferring and modifying customer service contract records. |
| KKW02516SFBean | Bean | The screen bean class that holds the UI state and data model for screen KKA16801SF. |
| KKW02516SF01DBean | Bean | A subclass of KKW02516SFBean that overrides list data handling for its own specialized list types (e.g., `ido_rsn_cd_list`, `op_svc_kei_no_list`). |
| 共通情報ビューン | Term (Japanese) | Shared info view — a common UI list component infrastructure shared across multiple screens in the platform. |
| 基底クラス | Term (Japanese) | Base class — refers to `X33VViewBaseBean`, which handles generic/shared list operations. |
| 繰り返し指定項目 | Term (Japanese) | Repeated specification item — a UI form field type that supports multiple rows/entries (essentially a repeatable list input). |
| 項目ID | Term (Japanese) | Item ID — the internal identifier used to reference a UI form field or list component. |
| インデックス番号 | Term (Japanese) | Index number — the zero-based position of an element within a list. |
| リスト項目のインスタンスを削除します | Javadoc (Japanese) | Removes a list item instance — the method's documented purpose. |
