# Business Logic — KKW00130SF02DBean.addListDataInstance() [21 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00130SF.KKW00130SF02DBean` |
| Layer | View Bean (Web Presentation Layer) |
| Module | `KKW00130SF` (Package: `eo.web.webview.KKW00130SF`) |

## 1. Role

### KKW00130SF02DBean.addListDataInstance()

This method is a **lazy initialization factory** for list-based view data within the K-Opticom web view framework (X33). It creates and registers a typed list element on demand, following the **builder/routing design pattern** by inspecting a string key and dispatching to the appropriate data-type list handler. The method supports the **"Number List" (電話番号一覧リスト)** data type — specifically initializing the **Banpo Cancellation Request Control Code** (番ポ廃止依頼制御コード) list container when no existing list instance exists. It plays a central role in the X33V typed data model infrastructure, enabling screen beans to dynamically populate list structures without pre-allocating memory. The method is called by the parent view bean (`KKW00130SFBean`) during screen data binding, and by subclasses in the FUW family of screen beans that extend or delegate to this method via `super.addListDataInstance(key)`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(String key)"])

    START --> CHECK_NULL["key == null?"]

    CHECK_NULL -->|Yes| RETURN_NULL["Return -1"]
    CHECK_NULL -->|No| CHECK_KEY["key.equals(番ポ廃止依頼制御コード)?"]

    RETURN_NULL --> END_RETURN["Return / Next"]

    CHECK_KEY -->|Yes| CHECK_LIST["bmp_haishi_req_ctrl_cd_list == null?"]
    CHECK_KEY -->|No| RETURN_DEFAULT["Return -1"]

    CHECK_LIST -->|Yes| CREATE_LIST["bmp_haishi_req_ctrl_cd_list = new X33VDataTypeList()"]
    CHECK_LIST -->|No| CREATE_BEAN["KKW00130SF01DBean tmpBean = new KKW00130SF01DBean()"]

    CREATE_LIST --> CREATE_BEAN
    CREATE_BEAN --> ADD_TO_LIST["bmp_haishi_req_ctrl_cd_list.add(tmpBean)"]
    ADD_TO_LIST --> RETURN_INDEX["Return bmp_haishi_req_ctrl_cd_list.size() - 1"]

    RETURN_DEFAULT --> END_RETURN
    RETURN_INDEX --> END_RETURN
```

**CRITICAL — Constant Resolution:**
The condition `key.equals("番ポ廃止依頼制御コード")` resolves to the constant `KKW00130SFConst.BMP_HAISHI_REQ_CTRL_CD_02 = "番ポ廃止依頼制御コード"`, which is the **Banpo Cancellation Request Control Code** — a field identifier used in service contract change processing related to phone number cancellation (banpo = 番ポ = 電話番号 = phone number) requests.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item/data-type key that identifies which list to initialize. Currently supports the value `"番ポ廃止依頼制御コード"` (Banpo Cancellation Request Control Code), which triggers creation of the list container for phone number cancellation service change control data. The key acts as a routing discriminator that dispatches to the appropriate typed list handler. |

**Instance fields read by this method:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `bmp_haishi_req_ctrl_cd_list` | `X33VDataTypeList` | The list container for banpo (phone number) cancellation request control code data elements. May be null on first call, requiring lazy initialization. |

## 4. CRUD Operations / Called Services

This method does **not** perform any CRUD operations or call any external services (SC/CBS). It operates entirely within the view bean layer, creating in-memory data structures.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| *(none)* | — | — | — | No database or service component calls — purely an in-memory list initialization utility |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW00130SF | `KKW00130SFBean` (parent view bean delegates/extends) | — (in-memory only) |

**Notes on caller discovery:**
- The method is overridden in multiple subclasses in the FUW family (e.g., `FUW00901SFBean`, `FUW00919SFBean`, `FUW00927SFBean`, `FUW00957SFBean`, `FUW00964SFBean`) — these subclasses call `super.addListDataInstance(key)` to inherit the base implementation, indicating it is part of a common inheritance chain.
- No direct callers outside the `KKW00130SF` package were found, confirming this is a self-contained view bean utility.

## 6. Per-Branch Detail Blocks

**Block 1** — IF (null check) `(key == null)` (L1631)

> Checks whether the key parameter is null. If null, the method returns -1 immediately without performing any initialization. This prevents NullPointerException and signals an invalid request.

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = parameter (null)` // Input parameter validation [-> CONSTANT_NAME=null] |
| 2 | RETURN | `return -1;` // 返す — Return early on null input (Japanese: nullの場合、-1で返す — returns -1 when key is null) |

**Block 2** — ELSE-IF (key match) `(key.equals("番ポ廃止依頼制御コード"))` `[BMP_HAISHI_REQ_CTRL_CD_02="番ポ廃止依頼制御コード"]` (L1634)

> Dispatches to the banpo cancellation request control code list handler. This is the only supported data type key currently implemented in this method. The constant `BMP_HAISHI_REQ_CTRL_CD_02` maps to the Japanese string "番ポ廃止依頼制御コード" — the Banpo (phone number) Cancellation Request Control Code item.

**Block 2.1** — IF (list null check) `(bmp_haishi_req_ctrl_cd_list == null)` (L1636)

> Checks whether the typed list container has already been initialized. If null (first call), creates a new empty `X33VDataTypeList` instance as the lazy initialization step.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bmp_haishi_req_ctrl_cd_list = new X33VDataTypeList()` // リストがnullの場合、新しい空のインスタンを生成 — If list is null, generate new empty instance (Japanese: リストがnullの場合、新しい空のインスタンスを生成する) |

**Block 2.2** — EXEC (bean creation) (L1639)

> Creates a new instance of `KKW00130SF01DBean` as the data-type bean model. This inner bean represents a single row/element within the banpo cancellation request control code list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `KKW00130SF01DBean tmpBean = new KKW00130SF01DBean()` // データタイプビューン型で指定したデータタイプビューンのインスタンスを生成する — Generate instance of specified data-type bean model (Japanese: データタイプビューン型で指定したデータタイプビューンのインスタンスを生成する) |
| 2 | SET | `// ただし、データタイプビューンの項目初期値設定は、各データビューン内で定義 — Item initial value settings are defined within each data bean (Japanese: なお、データタイプビューンの項目初期値設定は、各データビューン内で定義)` |

**Block 2.3** — EXEC (add to list) (L1640)

> Adds the newly created bean instance to the typed list container.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `bmp_haishi_req_ctrl_cd_list.add(tmpBean)` // Add the bean instance to the list container |

**Block 2.4** — RETURN (index return) (L1641)

> Returns the index of the newly added element. Since `add()` appends to the end, the index is `size() - 1`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return bmp_haishi_req_ctrl_cd_list.size() - 1;` // リストに追加された要素のインデックス番号を返す — Return the index number of the added element (Japanese: 追加された要素のインデックス番号 — index number of the added element) |

**Block 3** — ELSE (no matching key) (L1643)

> The provided key does not match any supported data type. Returns -1 to indicate no applicable handler was found.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // 該当する項目がない場合、-1を返す — Return -1 if no matching item exists (Japanese: 該当する項目がない場合、-1を返す) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `番ポ廃止依頼制御コード` | Field | Banpo Cancellation Request Control Code — The control code field for phone number cancellation (banpo = 電話番号 shorthand) service change requests. Used to track and control cancellation procedures in telecom service contracts. |
| `bmp_haishi_req_ctrl_cd` | Field | Abbreviation: BMP = 番ポ (banpo = phone number), HAISHI = 廃止 (cancellation), REQ = 依頼 (request), CTRL = 制御 (control), CD = コード (code). Internal code for the phone number cancellation request control code data element. |
| `X33VDataTypeList` | Class | X33 framework typed list container — a generic list that holds instances of typed data beans implementing `X33VDataTypeBeanInterface`. |
| `X33VDataTypeBeanInterface` | Interface | X33 framework interface for typed data beans that support model data retrieval via `typeModelData()` method. |
| `KKW00130SF01DBean` | Class | Inner data-type bean model used as elements within the banpo cancellation request control code list. Represents a single row of data in the list. |
| `KKW00130SF02DBean` | Class | View bean class that manages list-based view data for the KKW00130SF screen module. Extends `X33VViewBaseBean` and implements `X33VListedBeanInterface`. |
| `KKW00130SFBean` | Class | Parent view bean that delegates list data initialization to subtype beans like `KKW00130SF02DBean`. |
| X33 | Technology | Fujitsu X33 web application framework — a Java EE-based framework for building web screen applications with typed data beans and list model support. |
| K-Opticom | Business | K-Opticom — a Japanese telecommunications service provider (FTTH, phone, internet services). |
| 番ポ (banpo) | Abbreviation | Shorthand for 電話番号 (telephone number) — used in field names and comments throughout the codebase. |
| 廃止 (haishi) | Japanese term | Cancellation — as in service cancellation requests. |
| 依頼 (nyuu) | Japanese term | Request — as in service change/cancellation requests. |
| 制御コード (seigyo code) | Japanese term | Control code — a classification/dispatch code used for routing and controlling processing logic. |
| `BMP_HAISHI_REQ_CTRL_CD_02` | Constant | Constant value `"番ポ廃止依頼制御コード"` defined in `KKW00130SFConst`. Used as the list item key for banpo cancellation request control code. |
