# Business Logic — KKW05501SF01DBean.addListDataInstance() [43 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW05501SF.KKW05501SF01DBean` |
| Layer | UI Data Bean (Web Client / X33V framework) |
| Module | `KKW05501SF` (Package: `eo.web.webview.KKW05501SF`) |

## 1. Role

### KKW05501SF01DBean.addListDataInstance()

This method serves as a **lazy-initialized list factory** for the `KKW05501SF` screen's data bean. In the telecom order management domain, the screen manages code-type lookup tables — specifically, initial setup codes, code-type code values, and code-type name definitions. Rather than pre-allocating all list containers upfront, this method dynamically creates the underlying `X33VDataTypeList` collection on first access (if it does not yet exist) and appends one new `X33VDataTypeStringBean` element to it, returning the index of the newly added element.

It implements a **dispatch/routing pattern** based on a string key that identifies which list should be extended. Three distinct list types are supported: the initial-setup-code list (`default_cd_list`), the code-type-code-value list (`cd_div_cd_list_list`), and the code-type-name list (`cd_div_nm_list_list`). Each list holds beans of type `X33VDataTypeStringBean`, which are the framework's string-typed data carriers used by the X33V UI component system for binding list fields on the view.

This is a **shared utility method** within the data bean — it is not called directly by screens but is part of the bean's public API. Derived bean classes in other modules (e.g., `FUW00912SFBean`, `FUW00926SFBean`, `FUW00964SFBean`, and many others) override this method to add their own key branches, calling `super.addListDataInstance(key)` as a fallback. It plays the role of a **template method** in the bean hierarchy, enabling subclasses to extend list-data initialization logic without duplicating the base dispatch structure.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(String key)"])
    COND_NULL{"key == null"}
    COND_INIT{"key equals \"初期設定コード\""}
    COND_CD_VAL{"key equals \"コードタイプコード値リスト\""}
    COND_CD_NM{"key equals \"コードタイプ名称リスト\""}
    FINAL_RETURN(["Return -1"])

    START --> COND_NULL
    COND_NULL -->|true| FINAL_RETURN
    COND_NULL -->|false| COND_INIT
    COND_INIT -->|true| INIT_LIST_NULL{"default_cd_list == null"}
    COND_INIT -->|false| COND_CD_VAL
    INIT_LIST_NULL -->|true| INIT_LIST_NEW["default_cd_list = new X33VDataTypeList()"]
    INIT_LIST_NULL -->|false| INIT_CREATE_BEAN
    INIT_LIST_NEW --> INIT_CREATE_BEAN["tmpBean = new X33VDataTypeStringBean()"]
    INIT_CREATE_BEAN --> INIT_ADD["default_cd_list.add(tmpBean)"]
    INIT_ADD --> INIT_RETURN["Return default_cd_list.size() - 1"]
    INIT_RETURN --> FINAL_RETURN
    COND_CD_VAL -->|true| CDVAL_LIST_NULL{"cd_div_cd_list_list == null"}
    COND_CD_VAL -->|false| COND_CD_NM
    CDVAL_LIST_NULL -->|true| CDVAL_LIST_NEW["cd_div_cd_list_list = new X33VDataTypeList()"]
    CDVAL_LIST_NULL -->|false| CDVAL_CREATE_BEAN
    CDVAL_LIST_NEW --> CDVAL_CREATE_BEAN["tmpBean = new X33VDataTypeStringBean()"]
    CDVAL_CREATE_BEAN --> CDVAL_ADD["cd_div_cd_list_list.add(tmpBean)"]
    CDVAL_ADD --> CDVAL_RETURN["Return cd_div_cd_list_list.size() - 1"]
    CDVAL_RETURN --> FINAL_RETURN
    COND_CD_NM -->|true| CDNM_LIST_NULL{"cd_div_nm_list_list == null"}
    COND_CD_NM -->|false| FINAL_RETURN
    CDNM_LIST_NULL -->|true| CDNM_LIST_NEW["cd_div_nm_list_list = new X33VDataTypeList()"]
    CDNM_LIST_NULL -->|false| CDNM_CREATE_BEAN
    CDNM_LIST_NEW --> CDNM_CREATE_BEAN["tmpBean = new X33VDataTypeStringBean()"]
    CDNM_CREATE_BEAN --> CDNM_ADD["cd_div_nm_list_list.add(tmpBean)"]
    CDNM_ADD --> CDNM_RETURN["Return cd_div_nm_list_list.size() - 1"]
    CDNM_RETURN --> FINAL_RETURN
```

**Processing summary:**

1. **Null guard** (L688-690): If the key is `null`, return `-1` immediately. (Original: "nullの場合、-1で返す。" — "If null, return -1.")
2. **Branch: Initial Setup Code list** (L692-702): If the key matches "初期設定コード" (Initial Setup Code), ensure `default_cd_list` is initialized, create a new `X33VDataTypeStringBean`, add it, and return the index.
3. **Branch: Code Type Code Value list** (L704-714): If the key matches "コードタイプコード値リスト" (Code Type Code Value List), ensure `cd_div_cd_list_list` is initialized, create a new `X33VDataTypeStringBean`, add it, and return the index.
4. **Branch: Code Type Name list** (L716-726): If the key matches "コードタイプ名称リスト" (Code Type Name List), ensure `cd_div_nm_list_list` is initialized, create a new `X33VDataTypeStringBean`, add it, and return the index.
5. **Fallback** (L728): If none of the known keys matched, return `-1`. (Original: "該当する項目がない場合、-1を返す" — "If no matching item exists, return -1.")

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The name of the list item whose data instance should be created. This string acts as a dispatcher key that determines which internal list collection receives a new element. Valid values are: `"初期設定コード"` (Initial Setup Code — for `default_cd_list`), `"コードタイプコード値リスト"` (Code Type Code Value List — for `cd_div_cd_list_list`), or `"コードタイプ名称リスト"` (Code Type Name List — for `cd_div_nm_list_list`). An unrecognized value or `null` results in `-1` being returned. |

**Instance fields read by this method:**

| Field | Type | Usage |
|-------|------|-------|
| `default_cd_list` | `X33VDataTypeList` | Target list for initial setup code beans. Checked for null; lazily initialized on first access. |
| `cd_div_cd_list_list` | `X33VDataTypeList` | Target list for code-type code-value beans. Checked for null; lazily initialized on first access. |
| `cd_div_nm_list_list` | `X33VDataTypeList` | Target list for code-type name beans. Checked for null; lazily initialized on first access. |

## 4. CRUD Operations / Called Services

This method performs **pure in-memory data structure manipulation**. It does not call any SC (Service Component), CBS (Common Business Service), DAO, or external service methods. No database or entity operations are involved.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (N/A) | — | — | — | No external CRUD operations. All state changes are confined to the bean's in-memory `X33VDataTypeList` collections. |

The method creates new `X33VDataTypeStringBean` instances and appends them to existing lists, but this is **framework-level UI data binding state management**, not a persistence operation. The lists themselves are bound to the X33V UI component system (likely for `<x33v:selectManyListbox>` or similar components that display selectable code lists).

## 5. Dependency Trace

**Callers of this method:**

This method is defined in the base data bean `KKW05501SF01DBean` and is **not directly called by any screen or CBS**. Instead, it serves as a **base implementation** that is overridden by derived bean classes across the FUW009xxSF module family. The following classes override this method (their implementation delegates to `super.addListDataInstance(key)` as a fallback after adding their own key branches):

| # | Overriding Class | Relationship |
|---|-----------------|--------------|
| 1 | `FUW00901SFBean` | Overrides, calls `super.addListDataInstance(key)` |
| 2 | `FUW00907SFBean` / `FUW00907SF01DBean` | Overrides, calls `super.addListDataInstance(key)` |
| 3 | `FUW00912SF01DBean` | Standalone override (no super call) |
| 4 | `FUW00917SFBean` / `FUW00917SF01DBean` | Overrides, calls `super.addListDataInstance(key)` |
| 5 | `FUW00919SFBean` | Overrides, calls `super.addListDataInstance(key)` |
| 6 | `FUW00926SFBean` | Overrides, calls `super.addListDataInstance(key)` |
| 7 | `FUW00927SFBean` | Overrides, calls `super.addListDataInstance(key)` |
| 8 | `FUW00931SFBean` | Overrides, calls `super.addListDataInstance(key)` |
| 9 | `FUW00957SFBean` / `FUW00957SF01DBean` / `FUW00957SF05DBean` | Overrides, calls `super.addListDataInstance(key)` |
| 10 | `FUW00959SFBean` | Overrides, calls `super.addListDataInstance(key)` |
| 11 | `FUW00964SFBean` / `FUW00964SF01DBean` / `FUW00964SF04DBean` / `FUW00964SF07DBean` / `FUW00964SF10DBean` | Overrides, calls `super.addListDataInstance(key)` |

**Call chain pattern:**
```
Screen UI Event -> [DerivedBean.addListDataInstance(key)]
                   -> [Derived-specific branch] or
                   -> KKW05501SF01DBean.addListDataInstance(key)  // fallback
```

**What this method calls:**
- No external methods — only local variable access (`default_cd_list`, `cd_div_cd_list_list`, `cd_div_nm_list_list`) and framework constructors (`new X33VDataTypeList()`, `new X33VDataTypeStringBean()`).

## 6. Per-Branch Detail Blocks

### Block 1 — IF (null check) `(key == null)` (L688-690)

> Guard clause: if the key is null, return -1 immediately.
> Original comment: "nullの場合、-1で返す。" (If null, return -1.)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (key == null)` |
| 2 | RETURN | `return -1;` |

---

### Block 2 — ELSE-IF `(key.equals("初期設定コード"))` (L692-702)

> Branch for the "Initial Setup Code" list item. This list holds code-value beans used for initial configuration codes in the telecom service order system.
> Original comment: "配列項目 "初期設定コード"(String型、項目ID:default_cd)" (Array item "Initial Setup Code" (String type, item ID: default_cd))
> Original comment: "リストがnullの場合、新しい空のインスタンスを生成する" (If the list is null, generate a new empty instance)
> Original comment: "データタイプビーン型で指定したデータタイプビーンインスタンスを生成する。なお、データタイプビーンの項目初期値設定は、各データビーン内で定義" (Generate the specified data-type bean instance as a data-type bean type. Note: the item initial value settings for the data-type bean are defined within each data bean)

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("初期設定コード"))` |
| 2 | IF | `if (default_cd_list == null)` |
| 3 | SET | `default_cd_list = new X33VDataTypeList();` — lazy initialization of the list |
| 4 | EXEC | `new X33VDataTypeStringBean()` — instantiate a string-type data bean |
| 5 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 6 | CALL | `default_cd_list.add(tmpBean);` — append to the list |
| 7 | RETURN | `return default_cd_list.size() - 1;` — return zero-based index |

#### Block 2.1 — ELSE (list already exists) `(default_cd_list != null)` (L700-702)

> The list was already initialized (e.g., in the constructor or by a prior call). Skip initialization, go straight to bean creation.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | (implicit: list already initialized) |
| 2 | EXEC | `new X33VDataTypeStringBean()` |
| 3 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 4 | CALL | `default_cd_list.add(tmpBean);` |
| 5 | RETURN | `return default_cd_list.size() - 1;` |

---

### Block 3 — ELSE-IF `(key.equals("コードタイプコード値リスト"))` (L704-714)

> Branch for the "Code Type Code Value List". This list holds code-value beans representing the actual values of code types used in the telecom system.
> Original comment: "配列項目 "コードタイプコード値リスト"(String型、項目ID:cd_div_cd_list)" (Array item "Code Type Code Value List" (String type, item ID: cd_div_cd_list_list))
> Original comment: "リストがnullの場合、新しい空のインスタンスを生成する" (If the list is null, generate a new empty instance)

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("コードタイプコード値リスト"))` |
| 2 | IF | `if (cd_div_cd_list_list == null)` |
| 3 | SET | `cd_div_cd_list_list = new X33VDataTypeList();` — lazy initialization |
| 4 | EXEC | `new X33VDataTypeStringBean()` |
| 5 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 6 | CALL | `cd_div_cd_list_list.add(tmpBean);` |
| 7 | RETURN | `return cd_div_cd_list_list.size() - 1;` |

#### Block 3.1 — ELSE (list already exists) (L712-714)

| # | Type | Code |
|---|------|------|
| 1 | ELSE | (implicit: list already initialized) |
| 2 | EXEC | `new X33VDataTypeStringBean()` |
| 3 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 4 | CALL | `cd_div_cd_list_list.add(tmpBean);` |
| 5 | RETURN | `return cd_div_cd_list_list.size() - 1;` |

---

### Block 4 — ELSE-IF `(key.equals("コードタイプ名称リスト"))` (L716-726)

> Branch for the "Code Type Name List". This list holds code-value beans representing the human-readable names of code types.
> Original comment: "配列項目 "コードタイプ名称リスト"(String型、項目ID:cd_div_nm_list)" (Array item "Code Type Name List" (String type, item ID: cd_div_nm_list_list))
> Original comment: "リストがnullの場合、新しい空のインスタンスを生成する" (If the list is null, generate a new empty instance)

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("コードタイプ名称リスト"))` |
| 2 | IF | `if (cd_div_nm_list_list == null)` |
| 3 | SET | `cd_div_nm_list_list = new X33VDataTypeList();` — lazy initialization |
| 4 | EXEC | `new X33VDataTypeStringBean()` |
| 5 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 6 | CALL | `cd_div_nm_list_list.add(tmpBean);` |
| 7 | RETURN | `return cd_div_nm_list_list.size() - 1;` |

#### Block 4.1 — ELSE (list already exists) (L724-726)

| # | Type | Code |
|---|------|------|
| 1 | ELSE | (implicit: list already initialized) |
| 2 | EXEC | `new X33VDataTypeStringBean()` |
| 3 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 4 | CALL | `cd_div_nm_list_list.add(tmpBean);` |
| 5 | RETURN | `return cd_div_nm_list_list.size() - 1;` |

---

### Block 5 — ELSE (fallback) `(no key matched)` (L728)

> No recognized key was provided. Return -1 to indicate the operation was not performed.
> Original comment: "該当する項目がない場合、-1を返す" (If no matching item exists, return -1)

| # | Type | Code |
|---|------|------|
| 1 | ELSE | (implicit: none of the if/else-if branches matched) |
| 2 | RETURN | `return -1;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `default_cd_list` | Field | Initial setup code list — holds bean instances for default/initial configuration codes in the telecom service system |
| `cd_div_cd_list_list` | Field | Code type code-value list — holds the actual values of code type definitions (e.g., the code values used in lookup tables) |
| `cd_div_nm_list_list` | Field | Code type name list — holds the human-readable names corresponding to code type definitions |
| `初期設定コード` | Japanese field label | Initial Setup Code — a display label for the initial/default configuration code list item |
| `コードタイプコード値リスト` | Japanese field label | Code Type Code Value List — a display label for the code value list item |
| `コードタイプ名称リスト` | Japanese field label | Code Type Name List — a display label for the code name list item |
| `X33VDataTypeList` | Framework class | Fujitsu X33V framework's generic list data type — a type-safe collection for UI binding |
| `X33VDataTypeStringBean` | Framework class | String-typed data bean in the X33V framework — wraps a String value for UI data binding |
| `X33VListedBeanInterface` | Framework interface | Interface marking a bean as containing list-type data fields that can be bound to UI list components |
| `X33VDataTypeBeanInterface` | Framework interface | Interface marking a bean as a typed data holder in the X33V framework |
| L | Abbreviation | Line number in the source file (used in block references) |
| LOC | Abbreviation | Lines of Code (method length: 43) |
