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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA17701SF.KKW00129SF01DBean` |
| Layer | View / UI Data Binding (X33V DataType Bean) |
| Module | `KKA17701SF` (Package: `eo.web.webview.KKA17701SF`) |

## 1. Role

### KKW00129SF01DBean.addListDataInstance()

This method is a **data binding factory** that generates and registers instance elements within list-based UI data structures for the K-Opticom web client application. It operates as part of the Fujitsu X33V framework's data-binding mechanism, where each "key" parameter maps to a specific category of dropdown or multi-select form fields used in the telecom service contract management domain. The method follows a **dispatch/routing pattern**: it inspects the incoming string key against a fixed set of domain-specific list categories, and for each matching category, ensures a lazily-initialized `X33VDataTypeList` container exists, creates a new typed bean instance (`X33VDataTypeStringBean`), appends it to the container, and returns the index of the newly added element. Its role in the larger system is to serve as the UI-side counterpart to database-backed data lists, enabling screens to dynamically expand row-level selection data (such as initial-set code lists, code type lists, and code name lists) during page rendering or AJAX re-renders. The method is called indirectly via inheritance — subclasses like `KKW00129SFBean` route common information view requests through `super.addListDataInstance(key)` to reach this base implementation, and `KKW00129SF09DBean` provides its own override for extended list types.

**Branch summary:**
- **Branch 1 (Null guard):** If `key` is `null`, return `-1` immediately.
- **Branch 2 (Initial-set code list):** If `key` equals `"初期設定コードリスト"` (Initial-Set Code List), manage the `default_cd_list_list` field.
- **Branch 3 (Code list):** If `key` equals `"コードリスト"` (Code List), manage the `cd_div_cd_list_list` field.
- **Branch 4 (Code name list):** If `key` equals `"コード名リスト"` (Code Name List), manage the `cd_div_nm_list_list` field.
- **Default:** If no key matches, return `-1` indicating no matching item.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> COND_NULL["key == null"]
    COND_NULL -->|true| RET_NULL["return -1"]
    COND_NULL -->|false| COND_INIT["key equals 初期設定コードリスト"]

    COND_INIT -->|true| INIT_NULL_CHECK["default_cd_list_list == null"]
    INIT_NULL_CHECK -->|true| INIT_NEW_LIST["default_cd_list_list = new X33VDataTypeList()"]
    INIT_NULL_CHECK -->|false| INIT_NEW_BEAN
    INIT_NEW_LIST --> INIT_NEW_BEAN["tmpBean = new X33VDataTypeStringBean()"]

    COND_INIT -->|false| COND_CODE["key equals コードリスト"]

    INIT_NEW_BEAN --> INIT_ADD["default_cd_list_list.add(tmpBean)"]
    INIT_ADD --> INIT_RET["return default_cd_list_list.size() - 1"]

    COND_CODE -->|true| CODE_NULL_CHECK["cd_div_cd_list_list == null"]
    CODE_NULL_CHECK -->|true| CODE_NEW_LIST["cd_div_cd_list_list = new X33VDataTypeList()"]
    CODE_NULL_CHECK -->|false| CODE_NEW_BEAN
    CODE_NEW_LIST --> CODE_NEW_BEAN["tmpBean = new X33VDataTypeStringBean()"]

    COND_CODE -->|false| COND_NAME["key equals コード名リスト"]

    CODE_NEW_BEAN --> CODE_ADD["cd_div_cd_list_list.add(tmpBean)"]
    CODE_ADD --> CODE_RET["return cd_div_cd_list_list.size() - 1"]

    COND_NAME -->|true| NAME_NULL_CHECK["cd_div_nm_list_list == null"]
    NAME_NULL_CHECK -->|true| NAME_NEW_LIST["cd_div_nm_list_list = new X33VDataTypeList()"]
    NAME_NULL_CHECK -->|false| NAME_NEW_BEAN
    NAME_NEW_LIST --> NAME_NEW_BEAN["tmpBean = new X33VDataTypeStringBean()"]

    COND_NAME -->|false| RET_DEFAULT["return -1"]

    NAME_NEW_BEAN --> NAME_ADD["cd_div_nm_list_list.add(tmpBean)"]
    NAME_ADD --> NAME_RET["return cd_div_nm_list_list.size() - 1"]

    RET_NULL --> END(["End"])
    INIT_RET --> END
    CODE_RET --> END
    NAME_RET --> END
    RET_DEFAULT --> END
```

**CRITICAL — Constant Resolution:**
This method does not use external constant classes for its conditions. All three string literals are hardcoded domain labels directly comparing against the `key` parameter:

| Constant (Hardcoded) | Actual Value | Business Meaning |
|----------------------|-------------|-----------------|
| `"初期設定コードリスト"` | `"初期設定コードリスト"` (Initial-Set Code List) | List of preset/default code values used for initial configuration screens |
| `"コードリスト"` | `"コードリスト"` (Code List) | List of classification codes (e.g., service type codes, region codes) |
| `"コード名リスト"` | `"コード名リスト"` (Code Name List) | List of human-readable code labels displayed in dropdowns and selection UIs |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | A domain-specific list category identifier that determines which data binding list the method should manage. It represents a human-readable label of a UI list type (e.g., "初期設定コードリスト" for initial-set codes, "コードリスト" for code types, "コード名リスト" for code names). The value dictates which instance field (`default_cd_list_list`, `cd_div_cd_list_list`, or `cd_div_nm_list_list`) receives a new element. If the key does not match any known category, the method returns -1. |

**Instance fields read by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `default_cd_list_list` | `X33VDataTypeList` | Container list for initial-set code entries. Represents a collection of default/preset code values available on configuration screens. |
| 2 | `cd_div_cd_list_list` | `X33VDataTypeList` | Container list for code type (division code) entries. Represents a collection of classification codes used for categorizing service items. |
| 3 | `cd_div_nm_list_list` | `X33VDataTypeList` | Container list for code name (division name) entries. Represents a collection of human-readable code labels displayed in UI selection controls. |

## 4. CRUD Operations / Called Services

This method performs **no database operations, no SC/CBS calls, and no external service invocations**. It is a pure in-memory data structure management method within the UI bean layer. All operations are local `X33VDataTypeList` manipulations:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — (UI In-Memory) | *(none)* | — | — | Local list management only. No SC/CBS, no DB, no entity access. |

**In-memory operations breakdown:**

| # | Operation | Data Structure | Business Description |
|---|-----------|---------------|---------------------|
| 1 | Read | `default_cd_list_list`, `cd_div_cd_list_list`, `cd_div_nm_list_list` | Null-check on existing list containers to determine if lazy initialization is needed |
| 2 | Create | `new X33VDataTypeList()` | Instantiate a new empty typed list when the container is first accessed |
| 3 | Create | `new X33VDataTypeStringBean()` | Instantiate a new string-type bean for the element being added to the list |
| 4 | Create (C) | `X33VDataTypeList.add(X33VDataTypeStringBean)` | Append a new element to the in-memory list (UI-side, no persistence) |
| 5 | Read (R) | `X33VDataTypeList.size()` | Read list size to compute the zero-based index of the newly added element |

## 5. Dependency Trace

This method has **no external callers** — it is not invoked directly by any screen, batch, or controller class in the codebase. It participates in a **method delegation chain** through Java inheritance:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Inheritance: KKW00129SFBean | `KKW00129SFBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `KKW00129SF01DBean.addListDataInstance(key)` | *(none — in-memory only)* |
| 2 | Inheritance: KKW00129SF09DBean | `KKW00129SF09DBean.addListDataInstance(key)` → *(own override — does not call super)* | *(none — in-memory only)* |

**Notes:**
- `KKW00129SFBean` (the main Bean class) overrides `addListDataInstance()` to extend it with additional list types (e.g., "jimu_commision" / 事務手数料 Service fee) and delegates unmatched keys to `super.addListDataInstance(key)`, which chains to this `KKW00129SF01DBean` implementation.
- `KKW00129SF09DBean` provides its own full override and does **not** call `super.addListDataInstance()`.
- This method is an end of line — it performs no downstream calls to SC, CBS, or DB layers.

## 6. Per-Branch Detail Blocks

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

> Null guard: if the key parameter is null, return -1 immediately. This prevents NullPointerException in subsequent string comparisons.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // nullの場合、-1で返す (Return -1 if null) |

**Block 2** — [ELSE-IF] `(key.equals("初期設定コードリスト"))` [初期設定コードリスト="初期設定コードリスト"] (L696)

> Initial-set code list branch: manage the `default_cd_list_list` container. If the list is null, create a new empty `X33VDataTypeList`. Then create a new `X33VDataTypeStringBean` instance and add it to the list. Returns the zero-based index of the newly added element.

| # | Type | Code |
|---|------|------|
| 1 | SET | `default_cd_list_list = new X33VDataTypeList();` // リストがnullの場合、新しい空のインスタンスを生成 (If list is null, generate new empty instance) [L700-701] |
| 2 | SET | `tmpBean = new X33VDataTypeStringBean();` // データタイプがデータタイプビューン型の項目インスタンスを生成する (Generate instance of specified data type bean) [-> DATA_TYPE=X33VDataTypeStringBean] (L703-704) |
| 3 | EXEC | `default_cd_list_list.add(tmpBean);` // Add bean to list (L706) |
| 4 | RETURN | `return default_cd_list_list.size() - 1;` // Returns index of added element (L707) |

**Block 3** — [ELSE-IF] `(key.equals("コードリスト"))` [コードリスト="コードリスト"] (L711)

> Code list branch: manage the `cd_div_cd_list_list` container. Same pattern as Block 2 — lazy initialization of `X33VDataTypeList`, creation of a `X33VDataTypeStringBean`, append to list, return index.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cd_div_cd_list_list = new X33VDataTypeList();` // リストがnullの場合、新しい空のインスタンスを生成 (If list is null, generate new empty instance) [L715-716] |
| 2 | SET | `tmpBean = new X33VDataTypeStringBean();` // データタイプがデータタイプビューン型の項目インスタンスを生成する (Generate instance of specified data type bean) [-> DATA_TYPE=X33VDataTypeStringBean] (L718-719) |
| 3 | EXEC | `cd_div_cd_list_list.add(tmpBean);` // Add bean to list (L721) |
| 4 | RETURN | `return cd_div_cd_list_list.size() - 1;` // Returns index of added element (L722) |

**Block 4** — [ELSE-IF] `(key.equals("コード名リスト"))` [コード名リスト="コード名リスト"] (L726)

> Code name list branch: manage the `cd_div_nm_list_list` container. Same pattern as Blocks 2 and 3.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cd_div_nm_list_list = new X33VDataTypeList();` // リストがnullの場合、新しい空のインスタンスを生成 (If list is null, generate new empty instance) [L730-731] |
| 2 | SET | `tmpBean = new X33VDataTypeStringBean();` // データタイプがデータタイプビューン型の項目インスタンスを生成する (Generate instance of specified data type bean) [-> DATA_TYPE=X33VDataTypeStringBean] (L732-733) |
| 3 | EXEC | `cd_div_nm_list_list.add(tmpBean);` // Add bean to list (L735) |
| 4 | RETURN | `return cd_div_nm_list_list.size() - 1;` // Returns index of added element (L736) |

**Block 5** — [ELSE] (default, unmatched key) (L739)

> Fallback: when the key does not match any of the three known list categories, return -1 to indicate no matching item.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `default_cd_list_list` | Field | Initial-set code list — internal tracking list for preset/default code values used in configuration screens |
| `cd_div_cd_list_list` | Field | Code division code list — list of classification codes used for categorizing service items (e.g., service type, region) |
| `cd_div_nm_list_list` | Field | Code division name list — list of human-readable code labels displayed in UI dropdowns and selection controls |
| `key` | Parameter | List category identifier — a domain-specific string key that maps to one of three predefined list types for UI data binding |
| X33VDataTypeList | Framework type | Fujitsu X33V framework typed list container — a generic collection that holds elements of a specific data type for JSF/facelets UI binding |
| X33VDataTypeStringBean | Framework type | Fujitsu X33V framework string data type bean — a wrapper object for a single string value used in X33V typed lists |
| 初期設定コードリスト | Japanese label | Initial-Set Code List — a fixed set of default/preset code values used as starting options on configuration screens |
| コードリスト | Japanese label | Code List — a list of classification/division codes (e.g., service type codes) displayed as coded values in the UI |
| コード名リスト | Japanese label | Code Name List — a list of human-readable code labels/names displayed as descriptive text in dropdown selectors |
| K-Opticom | Business term | K-Opticom — Japanese telecommunications provider offering fiber-optic (FTTH) broadband, mobile, and bundled services |
| KKA17701SF | Module identifier | Screen module code — identifies the specific service screen feature (SF = Service Feature) within the K-Opticom web application suite |
| X33SException | Framework type | Fujitsu X33V framework checked exception — thrown for view-layer data binding errors |
