# Business Logic — KKW00401SF01DBean.addListDataInstance() [32 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00401SF.KKW00401SF01DBean` |
| Layer | View / Data Bean (Web Client framework data binding layer) |
| Module | `KKW00401SF` (Package: `eo.web.webview.KKW00401SF`) |

## 1. Role

### KKW00401SF01DBean.addListDataInstance()

This method is the instance factory for pre-defined list-type fields within the KKW00401SF screen data bean. It is invoked by the X33 Web Client framework's view data binding layer whenever a screen control requires a new element in a repeating (list) data field. The method dispatches based on the logical field name (`key`), routing to the appropriate internal `X33VDataTypeList` field, and creates a new `X33VDataTypeStringBean` element of the correct type. It implements the **Factory** pattern — specifically, a **Conditional Instance Factory** — by matching a string key to a predefined field and ensuring the target list is initialized before appending an element. Its role in the larger system is that of a shared **data binding utility** within the DBean hierarchy: the parent bean `KKW00401SFBean` delegates unresolved keys to `super.addListDataInstance(key)`, making this method the fallback handler for screen fields that belong specifically to the `KKW00401SF01DBean` data model. If two branches handle "Code Type Code Values List" and "Code Type Name List" — repeating fields for dropdown or list-based code selection controls on the service order screen.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(key)"])
    START --> CHECK_NULL["key is null?"]
    CHECK_NULL --> |Yes| RETURN_NEG1["Return -1"]
    CHECK_NULL --> |No| CHECK_TYPE_CD["key equals Code Type Code Values List?"]
    CHECK_TYPE_CD --> |Yes| INIT_CD_CD["cd_div_cd_list_list is null?"]
    INIT_CD_CD --> |Yes| NEW_CD_CD_LIST["cd_div_cd_list_list = new X33VDataTypeList()"]
    NEW_CD_CD_LIST --> NEW_TMP_BEAN_1["tmpBean = new X33VDataTypeStringBean()"]
    INIT_CD_CD --> |No| NEW_TMP_BEAN_1
    NEW_TMP_BEAN_1 --> ADD_1["cd_div_cd_list_list.add(tmpBean)"]
    ADD_1 --> RETURN_1["Return cd_div_cd_list_list.size() -1"]
    CHECK_TYPE_CD --> |No| CHECK_TYPE_NM["key equals Code Type Name List?"]
    CHECK_TYPE_NM --> |Yes| INIT_CD_NM["cd_div_nm_list_list is null?"]
    INIT_CD_NM --> |Yes| NEW_CD_NM_LIST["cd_div_nm_list_list = new X33VDataTypeList()"]
    NEW_CD_NM_LIST --> NEW_TMP_BEAN_2["tmpBean = new X33VDataTypeStringBean()"]
    INIT_CD_NM --> |No| NEW_TMP_BEAN_2
    NEW_TMP_BEAN_2 --> ADD_2["cd_div_nm_list_list.add(tmpBean)"]
    ADD_2 --> RETURN_2["Return cd_div_nm_list_list.size() -1"]
    CHECK_TYPE_NM --> |No| RETURN_FINAL["Return -1"]
    RETURN_NEG1 --> END(["End"])
    RETURN_1 --> END
    RETURN_2 --> END
    RETURN_FINAL --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The logical field name (item name) of a screen list control. It identifies which repeating data field needs a new instance. Values include `"コードタイプコード値リスト"` (Code Type Code Values List) for code value fields, and `"コードタイプ名称リスト"` (Code Type Name List) for code name/description fields. The key determines which internal list (`cd_div_cd_list_list` or `cd_div_nm_list_list`) receives the new element. |

**Instance fields / external state read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `cd_div_cd_list_list` | `X33VDataTypeList` | List of code type code value beans — holds the code value instances for the repeating code type dropdown |
| `cd_div_nm_list_list` | `X33VDataTypeList` | List of code type name beans — holds the code name/description instances corresponding to the code values |

## 4. CRUD Operations / Called Services

This method performs **no CRUD operations** and calls **no external services** (SC/CBS). It operates entirely within the view data bean layer, instantiating and populating local `X33VDataTypeList` collections.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No data access; pure in-memory bean instance factory |

## 5. Dependency Trace

This method is called indirectly through the X33 Web Client framework's view data binding mechanism. The bean hierarchy delegates unresolved keys to `super.addListDataInstance(key)`, so callers are not direct method invocations but rather framework-level dispatch from screen controls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW00401 (via KKW00401SFBean) | `KKW00401SFBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00401SF01DBean.addListDataInstance(key)` | No terminal — view-level bean only |
| 2 | Screen:KKW00401 (via KKW00401SF02DBean) | `KKW00401SF02DBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00401SF01DBean.addListDataInstance(key)` | No terminal — view-level bean only |
| 3 | Screen:KKW00401 (via KKW00401SF09DBean) | `KKW00401SF09DBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00401SF01DBean.addListDataInstance(key)` | No terminal — view-level bean only |
| 4 | Screen:KKW00401 (via KKW00401SF22DBean) | `KKW00401SF22DBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00401SF01DBean.addListDataInstance(key)` | No terminal — view-level bean only |
| 5 | Screen:KKW00401 (via KKW00401SF23DBean) | `KKW00401SF23DBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00401SF01DBean.addListDataInstance(key)` | No terminal — view-level bean only |
| 6 | Screen:KKW00401 (via KKW00401SF25DBean) | `KKW00401SF25DBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00401SF01DBean.addListDataInstance(key)` | No terminal — view-level bean only |

## 6. Per-Branch Detail Blocks

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

> Early return guard: if the field key is null, no instance is created and -1 is returned.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Null key check — return -1 to indicate failure |

---

**Block 2** — [ELSE-IF] `(key.equals("コードタイプコード値リスト")) [CODE_TYPE_CODE_VALUES_LIST]` (L666)

> Handles the Code Type Code Values List field (item ID: `cd_div_cd_list`). Generates a new `X33VDataTypeStringBean` and adds it to the code type code value list.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("コードタイプコード値リスト")` // "Code Type Code Values List" — check if key matches code values repeating field |
| 2 | SET | `cd_div_cd_list_list = new X33VDataTypeList()` // If list is null, create a new empty X33VDataTypeList — only if null check triggers (L668) |
| 3 | SET | `tmpBean = new X33VDataTypeStringBean()` // Create a new String-type data bean instance for the repeating element (L670-671) |
| 4 | EXEC | `cd_div_cd_list_list.add(tmpBean)` // Add the newly created bean to the code type code value list (L672) |
| 5 | RETURN | `return cd_div_cd_list_list.size() - 1;` // Return the 0-based index of the newly added element |

---

**Block 3** — [ELSE-IF] `(key.equals("コードタイプ名称リスト")) [CODE_TYPE_NAME_LIST]` (L677)

> Handles the Code Type Name List field (item ID: `cd_div_nm_list`). Generates a new `X33VDataTypeStringBean` and adds it to the code type name list.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("コードタイプ名称リスト")` // "Code Type Name List" — check if key matches code name repeating field |
| 2 | SET | `cd_div_nm_list_list = new X33VDataTypeList()` // If list is null, create a new empty X33VDataTypeList — only if null check triggers (L679) |
| 3 | SET | `tmpBean = new X33VDataTypeStringBean()` // Create a new String-type data bean instance for the repeating element (L681-682) |
| 4 | EXEC | `cd_div_nm_list_list.add(tmpBean)` // Add the newly created bean to the code type name list (L683) |
| 5 | RETURN | `return cd_div_nm_list_list.size() - 1;` // Return the 0-based index of the newly added element |

---

**Block 4** — [ELSE / FALL-THROUGH] `(key not matched)` (L686)

> Fallback: when the key does not match any of the defined list fields for this bean, return -1 to indicate the field is not recognized.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // No matching item — return -1 |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `cd_div_cd_list_list` | Field | Code Type Code Value List — the internal list holding repeating code value data beans for code type dropdown controls |
| `cd_div_nm_list_list` | Field | Code Type Name List — the internal list holding repeating code name/description data beans corresponding to the code values |
| `cd_div_cd_value` | Field | Code Type Code Value — the actual code value for a code type (e.g., a service code) |
| `cd_div_nm_value` | Field | Code Type Name Value — the display name/description for a code type |
| `X33VDataTypeStringBean` | Class | X33 Framework String Type Data Bean — a view data bean representing a single string value in the X33 Web Client framework, used as the element type for string-based repeating fields |
| `X33VDataTypeList` | Class | X33 Framework List Type Data — a view data collection type in the X33 Web Client framework, used to hold repeating list elements for screen controls |
| `X33VDataTypeBeanInterface` | Interface | X33 Framework Data Bean Interface — interface marking a class as a valid X33 view data bean, providing getter/setter contracts |
| `X33VListedBeanInterface` | Interface | X33 Framework Listed Bean Interface — interface enabling a data bean to participate in list-based (repeating) screen controls |
| `KKW00401SF` | Module | Service Order Screen Module — the K-Opticom screen module handling service order entry and management (likely Fiber To The Home / FTTH service order processing) |
| DBean | Abbreviation | Data Bean — a framework-managed JavaBean that holds the view-layer data model for a screen, including both single-value fields and repeating list fields |
| "コードタイプコード値リスト" | Japanese Field | Code Type Code Values List — the logical name of the repeating code value field; triggers creation of `cd_div_cd_list_list` elements |
| "コードタイプ名称リスト" | Japanese Field | Code Type Name List — the logical name of the repeating code name/description field; triggers creation of `cd_div_nm_list_list` elements |
| `X33SException` | Class | X33 Framework Exception — the checked exception type thrown by X33 Web Client framework methods for view-layer errors |
