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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.DKW00301SF.DKW00301SF05DBean` |
| Layer | Service / Data Bean (Web View Data Transfer Layer) |
| Module | `DKW00301SF` (Package: `eo.web.webview.DKW00301SF`) |

## 1. Role

### DKW00301SF05DBean.addListDataInstance()

This method implements a **factory pattern** for lazy-initializing and appending instances of typed data beans into a strongly-typed `X33VDataTypeList` collection, based on a string key that identifies the target list. It is a **key-driven dispatch method** — the caller passes a business-level item identifier (the "equipment provider code name list") and this method determines which internal list should receive the new entry, creates the appropriate bean instance (`DKW00301SF06DBean`), and appends it. The method plays a central role in the **K-Opticom returns acceptance screen** (`DKW00301` — 返品承認一覧会, "Returns Acceptance Overview Screen") by enabling dynamic construction of device-provider code lists used for data-binding to UI components. It functions as a shared utility called by bean hierarchy methods (`DKW00301SFBean`) and screen controllers, supporting the X33 framework's data-driven UI binding contract. The method has two branches: the primary branch handles creation of an equipment provider code entry (instantiating `DKW00301SF06DBean` and appending it to the `kiki_teikyo_cd_list_list`), and the fallback branch returns -1 when the key does not match any recognized list type.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(key)"])
    CHECK_NULL{key is null?}
    CHECK_EQ{key equals equipment provider code name list?}
    CHECK_LIST_NULL{list is null?}
    CREATE_LIST["create new X33VDataTypeList"]
    CREATE_BEAN["create new DKW00301SF06DBean"]
    ADD_TO_LIST["add bean to list"]
    RETURN_INDEX["return list.size - 1"]
    RETURN_MINUS1["return -1"]

    START --> CHECK_NULL
    CHECK_NULL -->|yes| RETURN_MINUS1
    CHECK_NULL -->|no| CHECK_EQ
    CHECK_EQ -->|yes| CHECK_LIST_NULL
    CHECK_EQ -->|no| RETURN_MINUS1
    CHECK_LIST_NULL -->|yes| CREATE_LIST
    CHECK_LIST_NULL -->|no| CREATE_BEAN
    CREATE_LIST --> CREATE_BEAN
    CREATE_BEAN --> ADD_TO_LIST
    ADD_TO_LIST --> RETURN_INDEX
    RETURN_INDEX --> END(["End"])
    RETURN_MINUS1 --> END
```

**Branching logic summary:**

- **Branch 1 — Null Key**: If the input `key` is `null`, the method returns `-1` immediately. This is a guard clause that prevents `NullPointerException` on the subsequent `equals()` call and signals "no item matched" to the caller.
- **Branch 2 — Known Key (機器提供コード名称リスト)**: If `key` equals the Japanese string `"機器提供コード名称リスト"` (literally "equipment provider code name list"), the method proceeds to lazy-initialize the internal list (if it has not yet been created), constructs a new `DKW00301SF06DBean` instance, appends it to the list, and returns the zero-based index of the newly added element.
- **Branch 3 — Unknown Key**: If `key` does not match the recognized string, the method returns `-1`, indicating no recognized item was found.

**Constant Resolution:** The condition `key.equals("機器提供コード名称リスト")` is a hardcoded string comparison against the literal Japanese text `"機器提供コード名称リスト"`. No external constant file was found that defines this string — it is inlined directly in the source code. This string serves as the unique dispatch key for the equipment provider code name list type.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item name / type identifier that determines which internal list to append to. In the context of this method, the expected value is the Japanese string `"機器提供コード名称リスト"` (Equipment Provider Code Name List), which represents the data structure used to hold a list of device/provider code entries on the returns acceptance screen. If `null`, the method returns `-1` as a guard clause. For any unrecognized key value, it also returns `-1`. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `kiki_teikyo_cd_list_list` | `X33VDataTypeList` | The target list storing `DKW00301SF06DBean` instances (each representing a single equipment provider code name entry). Lazy-initialized on first add if currently `null`. |

## 4. CRUD Operations / Called Services

This method performs **no direct database or SC (Service Component) calls**. It operates entirely at the data-bean level, constructing in-memory objects and manipulating an in-memory list. All calls are local object operations within the X33 framework's data binding infrastructure.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `new X33VDataTypeList()` | N/A | N/A (in-memory) | Creates a new empty typed data list instance when `kiki_teikyo_cd_list_list` is null. This is a factory/construction operation on the X33 data type collection. |
| C | `new DKW00301SF06DBean()` | N/A | N/A (in-memory) | Creates a new data bean instance representing a single equipment provider code name entry. This bean implements `X33VDataTypeBeanInterface` and `X33VListedBeanInterface` for X33 framework data binding. |
| C | `X33VDataTypeList.add()` | N/A | N/A (in-memory) | Appends the newly created `DKW00301SF06DBean` instance to the end of the `kiki_teikyo_cd_list_list` collection. Returns the index of the newly added element. |

**Note:** No Read/Update/Delete operations, SC calls, or database interactions occur within this method. It is purely an in-memory list-manipulation method.

## 5. Dependency Trace

This method is called through the bean hierarchy chain. The primary callers are:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Bean: `DKW00301SFBean` | `DKW00301SFBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `DKW00301SF05DBean.addListDataInstance(key)` | `new X33VDataTypeList() [C] (in-memory list)` |
| 2 | Bean: `DKW00301SFBean` | `DKW00301SFBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → `DKW00301SF05DBean.addListDataInstance(key)` | `new DKW00301SF06DBean() [C] (in-memory bean)` |

**Additional context on callers found across the codebase:**

Other `addListDataInstance` overrides exist in the codebase (e.g., `FUW00912SF01DBean`, `FUW00926SFBean`, `FUW00959SFBean`, etc.), and these are **different implementations** in different screen packages (`FUW*` series). The specific `DKW00301SF05DBean.addListDataInstance` is exclusively called through `DKW00301SFBean.addListDataInstance()` which delegates via `super.addListDataInstance(key)` to this parent method. The `DKW00301SFBean` is the main screen data bean for the returns acceptance overview screen.

## 6. Per-Branch Detail Blocks

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

> Guard clause: if the key parameter is null, return -1 immediately. This prevents a NullPointerException on the subsequent equals() call and signals that no recognized item was found.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key == null` |
| 2 | RETURN | `return -1;` // No matching item when key is null |

---

**Block 2** — [IF-ELSE-IF] `(key.equals("機器提供コード名称リスト"))` (L3623)

> Primary branch: when the key matches the equipment provider code name list identifier, ensure the internal list exists and append a new DKW00301SF06DBean instance to it. The key string `"機器提供コード名称リスト"` is the literal Japanese text meaning "Equipment Provider Code Name List" — it serves as the dispatch key for this specific data type.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("機器提供コード名称リスト")` // Dispatch key for equipment provider code name list |

**Block 2.1** — [IF] `(kiki_teikyo_cd_list_list == null)` (L3624)

> Lazy initialization: if the target list has not yet been created, instantiate a new empty `X33VDataTypeList`. This ensures the list exists before attempting to add elements to it.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `kiki_teikyo_cd_list_list == null` // List not yet initialized |
| 2 | SET | `kiki_teikyo_cd_list_list = new X33VDataTypeList()` // Create new empty typed data list |

**Block 2.2** — [PROCESSING STEP] (L3627)

> Create the data bean instance. A new `DKW00301SF06DBean` is instantiated. This bean implements `X33VDataTypeBeanInterface` and `X33VListedBeanInterface` and holds fields for a provider code name entry (code value, label, enabled state, display state). Initial value setup is defined within the data bean itself (as noted in the comment).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `DKW00301SF06DBean tmpBean = new DKW00301SF06DBean()` // Create new data type bean instance |

> Comment from source: データタイプデータタイプビューン型の項目"機器提供コード名称リスト"(項目ID:kiki_teikyo_cd_list)、データタイプビューン型のクラス名が"DKW00301SF06DBean"の例。データタイプビューン型の項目初期値設定は、各データビューン内で定義。

| # | Type | Code |
|---|------|------|
| 2 | EXEC | `kiki_teikyo_cd_list_list.add(tmpBean)` // Append the new bean to the list |
| 3 | RETURN | `return kiki_teikyo_cd_list_list.size() - 1` // Return zero-based index of the newly added element |

---

**Block 3** — [ELSE / FALLBACK] (L3632)

> Fallback: when the key does not match any recognized list type identifier, return -1 to signal that no matching item was found.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1` // No matching item — falls through as default case |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `機器提供コード名称リスト` | Field / Key | Equipment Provider Code Name List — the Japanese string key used to dispatch list item creation for the equipment/provider code name data type on the returns acceptance screen |
| `kiki_teikyo_cd_list_list` | Field | Equipment Provider Code List — an in-memory `X33VDataTypeList` storing `DKW00301SF06DBean` instances, each representing a single equipment provider code name entry |
| `DKW00301SF06DBean` | Class | Equipment Provider Code Name Data Bean — a data type bean implementing `X33VDataTypeBeanInterface` and `X33VListedBeanInterface`, holding fields for code value (`l_cd_value`), label (`l_nm_value`), enabled state, and display state for a provider code name entry |
| `DKW00301SF05DBean` | Class | Returns Acceptance Data Bean — the parent bean class implementing `X33VDataTypeBeanInterface` and `X33VListedBeanInterface`, holding fields for return acceptance screen data including choice flags, color codes, item numbers, order information, and the equipment provider code list |
| `DKW00301SF` | Module | Returns Acceptance Screen — the module code for the returns acceptance overview screen (返品承認一覧会) in the K-Opticom billing/operations system |
| `X33VDataTypeList` | Class | X33 Framework Typed Data List — a framework collection class that holds elements implementing `X33VDataTypeBeanInterface`, used for UI data binding in the X33 web framework |
| `X33VDataTypeBeanInterface` | Interface | X33 Framework Data Bean Interface — contract that beans must implement to serve as individual data entries in an `X33VDataTypeList` |
| `X33VListedBeanInterface` | Interface | X33 Framework Listed Bean Interface — contract for beans that represent list-type (multi-value) data fields |
| `X33SException` | Class | X33 Framework Service Exception — the checked exception type thrown by X33 framework methods for service-level errors |
| `l_cd_value` | Field | Code Value — the actual code value for a provider code name entry |
| `l_nm_value` | Field | Name Value — the display label/name for a provider code name entry |
| `l_cd_enabled` | Field | Code Enabled — boolean flag controlling whether the code value field is enabled in the UI |
| `l_nm_enabled` | Field | Name Enabled — boolean flag controlling whether the name value field is enabled in the UI |
| `l_cd_state` | Field | Code State — UI state string for the code value field |
| `l_nm_state` | Field | Name State — UI state string for the name value field |
| `l_cd_update` | Field | Code Update — update flag for the code value field |
| `l_nm_update` | Field | Name Update — update flag for the name value field |
