# Business Logic — KKW01601SF01DBean.addListDataInstance() [54 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA15301SF.KKW01601SF01DBean` |
| Layer | Web View / Data Bean (MVC View layer) |
| Module | `KKA15301SF` (Package: `eo.web.webview.KKA15301SF`) |

## 1. Role

### KKW01601SF01DBean.addListDataInstance()

This method is a **list data factory dispatcher** within the K-Opticom web application framework. It initializes and returns an index for a specific typed list of data instances on demand. In business terms, it supports the construction of multi-item input forms where certain fields (such as code values, code type names, initial setup codes, and credit exchange codes) need to hold a variable number of entries — the classic "repeatable row" pattern used in telecom service order screens.

The method implements a **routing/dispatch design pattern**: it examines the business string key passed as a parameter and routes to one of four pre-registered list types. For each type, if the underlying list has not yet been initialized (null), it creates a fresh `X33VDataTypeList` container and instantiates an `X33VDataTypeStringBean` item within it. The `X33VDataTypeStringBean` is a framework data type bean whose internal item initial values are defined by the data type library itself (no explicit default value setup is performed here).

Its role in the larger system is that of a **lazy-initialization utility** shared across the KKA15301SF screen module (service contract management). It is called by the parent bean (`KKW01601SFBean`) during view bean construction to ensure all repeatable list structures are instantiated before the page renders. Each branch handles a distinct domain concept:

- **"初期設定コード"** — Initial Setup Code: the default code used when a new line item is added to the form.
- **"コードタイプコード値リスト"** — Code Type Code Value List: the list of actual code values for repeatable code-type entries.
- **"コードタイプ名称リスト"** — Code Type Name List: the display names corresponding to each code-type entry.
- **"クレジット交換コード"** — Credit Exchange Code: the code used for credit card number pre-issuance service (introduced in project ANK-2565-00-00 Step 3).

If the key is `null` or does not match any registered list type, the method returns `-1`, signaling that no list item was created.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(key: String)"])
    CHECK_NULL{key is null?}
    NULL_RETURN(["Return -1"])
    ROUTE1["Route: key equals 初期設定コード"]
    ROUTE2["Route: key equals コードタイプコード値リスト"]
    ROUTE3["Route: key equals コードタイプ名称リスト"]
    ROUTE4["Route: key equals クレジット交換コード"]
    UNKNOWN_RETURN(["Return -1 (unrecognized key)"])
    CHECK_1{default_cd_list is null?}
    INIT_1["default_cd_list = new X33VDataTypeList()"]
    CREATE_1["new X33VDataTypeStringBean tmpBean"]
    ADD_1["default_cd_list.add(tmpBean)"]
    RETURN_1["Return default_cd_list.size() - 1"]
    CHECK_2{cd_div_cd_list_list is null?}
    INIT_2["cd_div_cd_list_list = new X33VDataTypeList()"]
    CREATE_2["new X33VDataTypeStringBean tmpBean"]
    ADD_2["cd_div_cd_list_list.add(tmpBean)"]
    RETURN_2["Return cd_div_cd_list_list.size() - 1"]
    CHECK_3{cd_div_nm_list_list is null?}
    INIT_3["cd_div_nm_list_list = new X33VDataTypeList()"]
    CREATE_3["new X33VDataTypeStringBean tmpBean"]
    ADD_3["cd_div_nm_list_list.add(tmpBean)"]
    RETURN_3["Return cd_div_nm_list_list.size() - 1"]
    CHECK_4{credit_kokan_cd_list is null?}
    INIT_4["credit_kokan_cd_list = new X33VDataTypeList()"]
    CREATE_4["new X33VDataTypeStringBean tmpBean"]
    ADD_4["credit_kokan_cd_list.add(tmpBean)"]
    RETURN_4["Return credit_kokan_cd_list.size() - 1"]

    START --> CHECK_NULL
    CHECK_NULL -->|true| NULL_RETURN
    CHECK_NULL -->|false| ROUTE1
    CHECK_NULL -->|false| ROUTE2
    CHECK_NULL -->|false| ROUTE3
    CHECK_NULL -->|false| ROUTE4
    ROUTE1 --> CHECK_1
    ROUTE2 --> CHECK_2
    ROUTE3 --> CHECK_3
    ROUTE4 --> CHECK_4
    CHECK_1 -->|true| INIT_1
    CHECK_1 -->|false| CREATE_1
    INIT_1 --> CREATE_1
    CREATE_1 --> ADD_1
    ADD_1 --> RETURN_1
    CHECK_2 -->|true| INIT_2
    CHECK_2 -->|false| CREATE_2
    INIT_2 --> CREATE_2
    CREATE_2 --> ADD_2
    ADD_2 --> RETURN_2
    CHECK_3 -->|true| INIT_3
    CHECK_3 -->|false| CREATE_3
    INIT_3 --> CREATE_3
    CREATE_3 --> ADD_3
    ADD_3 --> RETURN_3
    CHECK_4 -->|true| INIT_4
    CHECK_4 -->|false| CREATE_4
    INIT_4 --> CREATE_4
    CREATE_4 --> ADD_4
    ADD_4 --> RETURN_4
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | A Japanese-language label that identifies which list to initialize. It acts as a **routing discriminator** that maps to one of four domain-specific repeatable row types used in service contract input forms. Valid values are: `"初期設定コード"` (Initial Setup Code), `"コードタイプコード値リスト"` (Code Type Code Value List), `"コードタイプ名称リスト"` (Code Type Name List), or `"クレジット交換コード"` (Credit Exchange Code). The value directly determines which instance field (`default_cd_list`, `cd_div_cd_list_list`, `cd_div_nm_list_list`, or `credit_kokan_cd_list`) receives the new item. |

**Instance fields read by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `default_cd_list` | `X33VDataTypeList` | List holding initial setup code instances (item ID: `default_cd`) |
| 2 | `cd_div_cd_list_list` | `X33VDataTypeList` | List holding code type code value instances (item ID: `cd_div_cd_list`) |
| 3 | `cd_div_nm_list_list` | `X33VDataTypeList` | List holding code type name instances (item ID: `cd_div_nm_list`) |
| 4 | `credit_kokan_cd_list` | `X33VDataTypeList` | List holding credit exchange code instances (item ID: `credit_kokan_cd`) |

## 4. CRUD Operations / Called Services

This method performs **no database or service component (SC/CBS) calls**. It operates purely in the web view layer, managing in-memory data bean collections. All operations are **in-process memory manipulations**:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | *(none)* | — | — | This method has no SC/CBS calls, SQL operations, or entity/DB access. It is a pure view-bean factory method that initializes and populates in-memory `X33VDataTypeList` containers with `X33VDataTypeStringBean` items for use by the JSF view layer. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Bean:KKW01601SFBean | `KKW01601SFBean` (override) → `super.addListDataInstance(key)` → `KKW01601SF01DBean.addListDataInstance(key)` | *(none — in-memory only)* |
| 2 | Bean:KKW01601SF03DBean | `KKW01601SF03DBean` (overrides) — independent implementation at same class level | *(none — in-memory only)* |

**Caller context:**

- `KKW01601SFBean` (koptWebA): Contains an override at line 25740 that delegates to `super.addListDataInstance(key)` at line 25750, routing to this method. The parent bean uses `KKW01601SF01DBean` as a nested data bean, instantiated at multiple points during view initialization (lines 1669–1710).
- `KKW01601SF03DBean` (koptWebA): Contains its own independent override of `addListDataInstance` at line 1448. It does not call the parent `KKW01601SF01DBean` implementation.

## 6. Per-Branch Detail Blocks

> Each branch of the control flow is displayed as a hierarchical block structure.

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

> Early-exit guard: when `key` is `null`, return `-1` immediately.
> (nullの場合、-1で返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` |

---

**Block 2** — [ELSE-IF] `(key.equals("初期設定コード"))` — Initial Setup Code [default_cd] (L797)

> Branch for the "Initial Setup Code" list. Lazily initializes the `default_cd_list` container if it is null, then creates a new `X33VDataTypeStringBean` instance, adds it to the list, and returns the index of the newly added element.
> (配列項目 "初期設定コード" へ処理を行う。リストがnullの場合、新しい空のインスタンスを生成。)

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("初期設定コード")` |
| 2 | IF | `default_cd_list == null` (L799) |
| 2.1 | SET | `default_cd_list = new X33VDataTypeList();` |
| 3 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` (L801) // データタイプビーン型で指定したデータタイプビーンのインスタンスを生成。なお、データタイプビーンの項目初期値設定は、各データビーン内部で定義 — instantiate data type bean; internal default values defined within the data bean itself |
| 4 | CALL | `default_cd_list.add(tmpBean);` (L803) |
| 5 | RETURN | `return default_cd_list.size() - 1;` (L804) // 追加された要素のインデックス番号 — index of the added element |

---

**Block 3** — [ELSE-IF] `(key.equals("コードタイプコード値リスト"))` — Code Type Code Value List [cd_div_cd_list] (L809)

> Branch for the "Code Type Code Value List". Lazily initializes the `cd_div_cd_list_list` container if null, creates a new `X33VDataTypeStringBean`, adds it, and returns its index.
> (配列項目 "コードタイプコード値リスト" へ処理を行う。リストがnullの場合、新しい空のインスタンスを生成。)

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("コードタイプコード値リスト")` |
| 2 | IF | `cd_div_cd_list_list == null` (L811) |
| 2.1 | SET | `cd_div_cd_list_list = new X33VDataTypeList();` |
| 3 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` (L813) // データタイプビーン型で指定したデータタイプビーンのインスタンスを生成 — instantiate data type bean |
| 4 | CALL | `cd_div_cd_list_list.add(tmpBean);` (L815) |
| 5 | RETURN | `return cd_div_cd_list_list.size() - 1;` (L816) // 追加された要素のインデックス番号 — index of added element |

---

**Block 4** — [ELSE-IF] `(key.equals("コードタイプ名称リスト"))` — Code Type Name List [cd_div_nm_list] (L822)

> Branch for the "Code Type Name List". Lazily initializes the `cd_div_nm_list_list` container if null, creates a new `X33VDataTypeStringBean`, adds it, and returns its index.
> (配列項目 "コードタイプ名称リスト" へ処理を行う。リストがnullの場合、新しい空のインスタンスを生成。)

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("コードタイプ名称リスト")` |
| 2 | IF | `cd_div_nm_list_list == null` (L824) |
| 2.1 | SET | `cd_div_nm_list_list = new X33VDataTypeList();` |
| 3 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` (L826) // データタイプビーン型で指定したデータタイプビーンのインスタンスを生成 — instantiate data type bean |
| 4 | CALL | `cd_div_nm_list_list.add(tmpBean);` (L828) |
| 5 | RETURN | `return cd_div_nm_list_list.size() - 1;` (L829) // 追加された要素のインデックス番号 — index of added element |

---

**Block 5** — [ELSE-IF] `(key.equals("クレジット交換コード"))` — Credit Exchange Code [credit_kokan_cd] (L834)

> Branch for the "Credit Exchange Code" list. Introduced by project **ANK-2565-00-00** (Credit Card Number Pre-Issuance Service Step 3: pre-issuance numbering). Lazily initializes the `credit_kokan_cd_list` container if null, creates a new `X33VDataTypeStringBean`, adds it, and returns its index.
> (配列項目 "クレジット交換コード" へ処理を行う。リストがnullの場合、新しい空のインスタンスを生成。)

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("クレジット交換コード")` |
| 2 | IF | `credit_kokan_cd_list == null` (L836) |
| 2.1 | SET | `credit_kokan_cd_list = new X33VDataTypeList();` |
| 3 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` (L838) // データタイプビーン型で指定したデータタイプビーンのインスタンスを生成 — instantiate data type bean |
| 4 | CALL | `credit_kokan_cd_list.add(tmpBean);` (L840) |
| 5 | RETURN | `return credit_kokan_cd_list.size() - 1;` (L841) // 追加された要素のインデックス番号 — index of added element |

---

**Block 6** — [ELSE] (unrecognized key) (L842)

> Default fallback: when the key does not match any of the four registered list types, return `-1`.
> (該当する項目がない場合、-1を返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `default_cd_list` | Field | Initial setup code list — holds `X33VDataTypeStringBean` items representing the default code applied when a new line item is added to a service contract form. Item ID: `default_cd`. |
| `cd_div_cd_list_list` | Field | Code type code value list — holds `X33VDataTypeStringBean` items for the actual code values in repeatable code-type rows. Item ID: `cd_div_cd_list`. |
| `cd_div_nm_list_list` | Field | Code type name list — holds `X33VDataTypeStringBean` items for the display names of each code-type entry in repeatable rows. Item ID: `cd_div_nm_list`. |
| `credit_kokan_cd_list` | Field | Credit exchange code list — holds `X33VDataTypeStringBean` items for credit card number pre-issuance service codes. Introduced by ANK-2565-00-00 (Credit Card Number Pre-Issuance Service, Step 3). Item ID: `credit_kokan_cd`. |
| `cd_div_cd_update` | Field | Code type update indicator — tracks whether the code type field has been modified. |
| `cd_div_cd_value` | Field | Code type value — the current value of the code type field. |
| `cd_div_cd_enabled` | Field | Code type field enabled flag — whether the code type input is editable on the screen. |
| `cd_div_nm_update` | Field | Code type name update indicator. |
| `cd_div_nm_value` | Field | Code type name value. |
| `cd_div_nm_enabled` | Field | Code type name field enabled flag. |
| `select_index_update` | Field | Selected index update indicator. |
| `select_index_value` | Field | Currently selected index value. |
| `select_index_enabled` | Field | Selected index field enabled flag. |
| `select_index_state` | Field | Selected index state string. |
| `X33VDataTypeList` | Type | Fujitsu X33 framework list data type — a generic typed list container used to hold collections of `X33VDataTypeBeanInterface` objects in the web view layer. |
| `X33VDataTypeStringBean` | Type | Fujitsu X33 framework string data type bean — a typed bean wrapping a `String` value, used within `X33VDataTypeList` for repeatable form fields. |
| `X33VViewBaseBean` | Type | Base class for X33 view beans — the MVC view-layer base that provides getter/setter infrastructure and JSF integration. |
| `X33VListedBeanInterface` | Interface | X33 interface marking a bean as containing list-type data fields. |
| `X33SException` | Type | X33 framework checked exception for service-layer errors, declared in the method signature. |
| `KKA15301SF` | Module | Service Contract (Service Contents) Screen — the web screen module for managing telecom service contracts, including service type, code type, and credit card pre-issuance services. |
| KKW01601SF | Class prefix | K-Opticom Web, Service Contract 01601 Screen — the screen identifier prefix for this service contract data bean. |
| 初期設定コード | Japanese field | Initial Setup Code — the default/standard code applied when creating a new service contract line item. |
| コードタイプコード値リスト | Japanese field | Code Type Code Value List — the list of actual code values in repeatable code-type input rows. |
| コードタイプ名称リスト | Japanese field | Code Type Name List — the list of human-readable names corresponding to each code-type entry. |
| クレジット交換コード | Japanese field | Credit Exchange Code — the code used for credit card number pre-issuance service. |
| ANK-2565-00-00 | Project | Credit Card Number Pre-Issuance Service introduction — a project introducing credit card pre-issuance functionality (Step 3 focused on pre-issuance numbering). |
| ANK-2631-00-00 | Project | Windows Top Case — a migration project copying koptWebB to koptWebA (Step 1). |
| Step 1 / Step 3 | Project phase | Implementation phases of the credit card pre-issuance service. Step 1 = initial migration; Step 3 = pre-issuance numbering. |
| -1 | Sentinel | Return value indicating "no list item created" — used when `key` is null or unrecognized. |
