# Business Logic — KKW02701SF01DBean.removeElementFromListData() [20 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02701SF.KKW02701SF01DBean` |
| Layer | Web Component (WebView DBean — Data Bean for screen-level data management) |
| Module | `KKW02701SF` (Package: `eo.web.webview.KKW02701SF`) |

## 1. Role

### KKW02701SF01DBean.removeElementFromListData()

This method provides a **key-based polymorphic removal** utility for managing typed list data within the HKT (Hikari K-Opticom) telecommunications service contract management screen (KKW02701SF). It enables removal of a single item at a specified index from one of several heterogeneous data lists stored as `X33VDataTypeList` instances, dispatching the removal to the correct list based on a string key discriminator.

The method implements a **discriminator-based routing pattern**: the incoming `key` parameter is compared against hardcoded Japanese label strings, and each match routes to a dedicated instance field (`hktgi_ido_rsn_cd_list` or `hktgi_op_svc_kei_no_list`). This is a classic field-specific dispatcher used across the WebView framework to avoid having the calling screen logic know the internal structure of the DBean's data model.

This method serves as a **shared screen utility** called by the KKW02701SF screen flow when a user deletes a line item from a dynamically bound table — for example, removing a migration reason code or an optional service contract number from a list that is rendered in the UI. It has no CRD operations (no DB or service component calls); it operates entirely on in-memory list state, making it a lightweight data manipulation method.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["removeElementFromListData key index"])
    START --> CHECK_KEY{key is not null}
    CHECK_KEY --> No["no"]
    CHECK_KEY --> Yes["yes"]
    No --> END_RETURN(["return"])
    Yes --> CHECK_ISDO{異動理由コード}
    CHECK_ISDO --> YesIsdo["yes"]
    CHECK_ISDO --> NoIsdo["no"]
    YesIsdo --> CHECK_ISDO_IDX{index valid range}
    CHECK_ISDO_IDX --> YesIdx["yes"]
    CHECK_ISDO_IDX --> NoIdx["no"]
    YesIdx --> REMOVE_ISDO["hktgi_ido_rsn_cd_list remove"]
    NoIdx --> CHECK_OP{オプションサービス契約番号}
    REMOVE_ISDO --> CHECK_OP
    CHECK_OP --> YesOp["yes"]
    CHECK_OP --> NoOp["no"]
    YesOp --> CHECK_OP_IDX{index valid range}
    CHECK_OP_IDX --> YesOpIdx["yes"]
    CHECK_OP_IDX --> NoOpIdx["no"]
    YesOpIdx --> REMOVE_OP["hktgi_op_svc_kei_no_list remove"]
    NoOpIdx --> END_RETURN
    NoOp --> END_RETURN
    REMOVE_OP --> END_RETURN
```

**Processing Steps:**

1. **Null check on `key`** — The method immediately guards against a null key. If `key` is `null`, no removal occurs and the method returns. This prevents `NullPointerException` on the `key.equals(...)` calls that follow.

2. **Discriminator: "異動理由コード" (Migration Reason Code)** — If `key` equals the string literal `"異動理由コード"` (the Japanese label for the migration/reason code field), the method checks whether `index` is within the bounds of `hktgi_ido_rsn_cd_list`. If valid, it removes the element at that index from the list. The comment clarifies: "If the specified index is within the current list range, remove the content at that index."

3. **Discriminator: "オプションサービス契約番号" (Optional Service Contract Number)** — If `key` does not match the first label and instead equals `"オプションサービス契約番号"`, the method performs the same range-check-and-remove logic against the `hktgi_op_svc_kei_no_list` list.

4. **Unrecognized key** — If `key` matches neither discriminator, no action is taken. The method simply returns. There is no error logging or exception thrown for unknown keys.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The display label that identifies which list to modify. It acts as a discriminator routing removal to the correct `X33VDataTypeList` instance. Valid values are `"異動理由コード"` (Migration Reason Code — used for tracking reasons for service migration/discontinuation) or `"オプションサービス契約番号"` (Optional Service Contract Number — used for managing add-on service contract line items). A `null` value causes the method to return without performing any operation. |
| 2 | `index` | `int` | The zero-based position of the element to remove from the target list. Must be non-negative and strictly less than the target list's size. Out-of-range values are silently ignored (no bounds-check exception is thrown). |

**Instance fields read:**

| Field | Type | Business Meaning |
|-------|------|------------------|
| `hktgi_ido_rsn_cd_list` | `X33VDataTypeList` | List holding migration reason codes (String-type items, internal field ID: `hktgi_ido_rsn_cd`) used to explain why a service item is being moved or discontinued |
| `hktgi_op_svc_kei_no_list` | `X33VDataTypeList` | List holding optional service contract numbers (String-type items, internal field ID: `hktgi_op_svc_kei_no`) for add-on telecom services |

## 4. CRUD Operations / Called Services

This method performs **no CRD operations** and **no service component (SC) / CBS calls**. It operates entirely on in-memory `X33VDataTypeList` instances, making it a pure data manipulation method with no database or persistence layer interaction.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No external operations — local list mutation only |

## 5. Dependency Trace

The method `removeElementFromListData` is defined in `KKW02701SF01DBean` and is implemented as a virtual method (`public`), inherited by subclasses in other screen packages. The following screens contain subclasses that either override this method (and call `super.removeElementFromListData(key, index)`) or provide their own implementation:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW02701SF | `KKW02701SFBean` -> `KKW02701SF01DBean.removeElementFromListData` | None (local list mutation only) |

**Note:** Many other FUW-* screen beans (FUW00901SF, FUW00907SF, FUW00912SF, FUW00917SF, FUW00919SF, FUW00926SF, FUW00927SF, FUW00931SF, FUW00957SF, FUW00959SF, FUW00964SF) contain their own `removeElementFromListData` methods, many of which delegate to `super.removeElementFromListData(key, index)`. However, the specific implementation in `KKW02701SF01DBean` (with its `hktgi_*` field names) is unique to the KKW02701SF module and does not appear to be called from other screen packages — it is scoped to the KKW02701SF screen flow.

## 6. Per-Branch Detail Blocks

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

> Guard clause: prevent NullPointerException by checking that the key parameter is non-null before proceeding with discrimination.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `key.equals("異動理由コード")` // Check if key matches migration reason code label ("異動理由コード") |
| 2 | EXEC | `key.equals("オプションサービス契約番号")` // Check if key matches optional service contract number label ("オプションサービス契約番号") |

**Block 1.1** — [IF] `(key.equals("異動理由コード"))` [異動理由コード="1" (Migration Reason Code)] (L1510)

> Route removal to the migration reason code list when the key matches the Japanese label for migration reason codes.

| # | Type | Code |
|---|------|------|
| 1 | IF | `index >= 0 && index < hktgi_ido_rsn_cd_list.size()` // Check index is within list bounds |
| 1.1 | EXEC | `hktgi_ido_rsn_cd_list.remove(index)` // Remove element at the specified index from the migration reason code list |

> Comment (L1511): 指定のインデックスが現在のリストの範囲内なら、そのインデックスの内容を削除 // "If the specified index is within the current list range, remove the content at that index"

**Block 1.2** — [ELSE-IF] `(key.equals("オプションサービス契約番号"))` [オプションサービス契約番号="2" (Optional Service Contract Number)] (L1516)

> Route removal to the optional service contract number list when the key matches the Japanese label for optional service contract numbers.

| # | Type | Code |
|---|------|------|
| 1 | IF | `index >= 0 && index < hktgi_op_svc_kei_no_list.size()` // Check index is within list bounds |
| 1.1 | EXEC | `hktgi_op_svc_kei_no_list.remove(index)` // Remove element at the specified index from the optional service contract number list |

> Comment (L1517): 指定のインデックスが現在のリストの範囲内なら、そのインデックスの内容を削除 // "If the specified index is within the current list range, remove the content at that index"

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `異動理由コード` | Field (Japanese label) | Migration Reason Code — the Japanese display label for the `hktgi_ido_rsn_cd` field, used to classify why a service item is being moved, discontinued, or modified |
| `hktgi_ido_rsn_cd` | Field | HIKARI K-Opticom Migration Reason Code — internal field ID for storing the reason code associated with a service migration event |
| `hktgi_ido_rsn_cd_list` | Field | List holding migration reason code entries as `X33VDataTypeList` instances |
| `オプションサービス契約番号` | Field (Japanese label) | Optional Service Contract Number — the Japanese display label for the `hktgi_op_svc_kei_no` field, used to identify add-on telecom services |
| `hktgi_op_svc_kei_no` | Field | HIKARI K-Opticom Optional Service Contract Number — internal field ID for storing optional/add-on service contract identifiers |
| `hktgi_op_svc_kei_no_list` | Field | List holding optional service contract number entries as `X33VDataTypeList` instances |
| DBean | Acronym | Data Bean — a screen-level data container class in the WebView framework that holds form data and screen-specific business logic |
| X33VDataTypeList | Type | A custom framework data structure for managing typed list data in WebView screens, supporting polymorphic data binding |
| KKW02701SF | Screen ID | A HIKARI K-Opticom screen for managing service contract items, specifically handling migration and optional service configurations |
| HKTGI | Prefix | Hikari K-Opticom (internal project abbreviation used for field naming) |
| X33SException | Type | A checked exception from the X33 WebView framework used to signal screen-level business rule violations |
