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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW00943SF.FUW00943SF02DBean` |
| Layer | Service (Webview / D-Bean — DTO layer within the web presentation tier) |
| Module | `FUW00943SF` (Package: `eo.web.webview.FUW00943SF`) |

## 1. Role

### FUW00943SF02DBean.addListDataInstance()

This method is the factory entry point for creating and managing instances of the **"Answer Response List" (アンケート回答リスト)** data type within a survey/questionnaire feature of the K-Opticom telecommunications service management system. It implements a **string-key-based dispatcher pattern**: given a string `key` that identifies a data item type, it creates a typed instance, appends it to the corresponding in-memory list collection, and returns the zero-based index of the newly added element. 

Specifically, this method handles the fixed data type **"Answer Response List" (アンケート回答リスト)**, which is a repeated (list) data type where each element is an instance of `FUW00943SF06DBean` — a data-type bean representing a single survey answer response. If the list has not yet been initialized (i.e., `enquete_answer_list_list` is null), the method lazily instantiates it as a new `X33VDataTypeList` before appending the new bean. This lazy initialization ensures the list collection exists only when actually needed.

The method is part of the X33 framework's listed-bean interface (`X33VListedBeanInterface`), which enables dynamic list-based form binding for JavaServer Faces (JSF) screens. It serves as a shared utility within the `FUW00943SF` module — a survey data management screen module — supporting the construction and manipulation of survey answer data structures at runtime. The method has no external side effects (no DB writes, no service component calls) and operates purely on in-memory bean collections.

## 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_TYPE{"key equals アンケート回答リスト?"}

    COND_TYPE --> |true| CHECK_LIST{"enquete_answer_list_list == null?"}
    CHECK_LIST --> |true| INIT_LIST["enquete_answer_list_list = new X33VDataTypeList"]
    INIT_LIST --> CREATE_BEAN["tmpBean = new FUW00943SF06DBean"]

    CHECK_LIST --> |false| CREATE_BEAN
    CREATE_BEAN --> ADD_LIST["enquete_answer_list_list.add tmpBean"]
    ADD_LIST --> RET_INDEX["Return enquete_answer_list_list.size - 1"]

    COND_TYPE --> |false| RET_FALLBACK["Return -1"]

    RET_NULL --> END(("END"))
    RET_INDEX --> END
    RET_FALLBACK --> END
```

**CRITICAL — Constant Resolution:**
- The condition `key.equals("アンケート回答リスト")` compares against the **hardcoded string literal** `"アンケート回答リスト"` (Answer Response List). This is the business-facing label of the data type item, matching the field's `itemID` used in the X33 framework's data loading mechanism.

**Requirements:**
- The method has two conditional branches: (1) null guard, and (2) data-type key matching.
- When the key matches, there is a nested check for lazy initialization of the list.
- All branches return an integer: the zero-based index on success, or `-1` on any failure/unsupported key.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The business-facing label of a data item type. When the value is `"アンケート回答リスト"` (Answer Response List), this method creates a new survey answer response bean and appends it to the in-memory list. Other values result in a `-1` return (unsupported key). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `enquete_answer_list_list` | `X33VDataTypeList` | The list collection holding survey answer response beans (`FUW00943SF06DBean` instances). May be `null` if the list has not yet been initialized. |

## 4. CRUD Operations / Called Services

This method performs **purely in-memory bean collection operations** — it does not invoke any Service Components (SC), Call-back Services (CBS), or database operations. All operations are local to the D-Bean instance.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| N/A | — | — | `enquete_answer_list_list` (in-memory `X33VDataTypeList`) | Lazy initialization of the survey answer list collection. |
| N/A | — | — | `FUW00943SF06DBean` (in-memory) | Instantiation of a new survey answer response bean. |
| N/A | — | — | `enquete_answer_list_list` (in-memory) | Appending a new bean instance to the answer list. |

## 5. Dependency Trace

**Callers of this method (within the FUW00943SF module):**

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `FUW00943SFBean` (super class) | Inherits the same-signature method; delegates via `super.addListDataInstance(key)` at L2204. | N/A (parent class method) |

**Note:** The `addListDataInstance` method in `FUW00943SF02DBean` is defined at lines 663–683 and is a leaf method — it does not itself call any other application-layer methods (no SC, CBS, or DAO calls). Its only external dependencies are framework types from the X33 library (`X33VDataTypeList`, `X33VDataTypeBeanInterface`) and the bean class `FUW00943SF06DBean`.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(key == null)` (L665–667)

> Null guard: if the caller passes a null key, immediately return `-1` without further processing. This prevents `NullPointerException` on the subsequent `equals()` call.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // If key is null, return -1 (nullの场合、-1で返す。) |

**Block 2** — [ELSE-IF] `(key.equals("アンケート回答リスト"))` [アンケート回答リスト="Answer Response List"] (L670–681)

> Data-type key dispatch: when the key matches the survey answer response list label, create a new bean instance and append it to the list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `key.equals("アンケート回答リスト")` // Compare against hardcoded label: "Answer Response List" (各繰り返し項目の固定要素数指定への処理。) |

**Block 2.1** — [NESTED IF] `(enquete_answer_list_list == null)` (L671–673)

> Lazy initialization: if the list collection has not been created yet, instantiate a new empty `X33VDataTypeList`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `enquete_answer_list_list = new X33VDataTypeList();` // If list is null, generate a new empty instance (リストがnullの場合、新しい空のインスタンスを生成する) |

**Block 2.2** — (L674–675) [unconditional within the match branch]

> Instantiate the typed bean and add it to the list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `FUW00943SF06DBean tmpBean = new FUW00943SF06DBean();` // Generate instance of the data-type bean for the specified data type (データタイプビーン型で指定したデータタイプビーンのインスタンスを生成する。) |
| 2 | EXEC | `enquete_answer_list_list.add(tmpBean);` // Append the newly created bean to the list |
| 3 | RETURN | `return enquete_answer_list_list.size() - 1;` // Return the zero-based index of the added element (追加された要素のインデックス番号) |

**Block 3** — [ELSE] `(key matches no known data type)` (L682)

> Fallback: when the key does not match any supported data type label, return `-1` to indicate the item is unknown.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `アンケート回答リスト` | Field/Label | Answer Response List — the business-facing label used as a data type key to identify the repeated survey answer list data item |
| `FUW00943SF06DBean` | Class | Data-type bean for a single survey answer response record within the FUW00943SF module |
| `X33VDataTypeList` | Class | X33 framework list type — a typed collection for holding repeated/iterated data items in the view model |
| `X33VListedBeanInterface` | Interface | X33 framework contract for beans that manage list-type data items via `addListDataInstance` and related methods |
| `X33SException` | Exception | X33 framework checked exception for service-level errors |
| X33 | Acronym | Fujitsu Futurity Web X33 — an internal Java web application framework (Web Client tool V01/L01) for building JSF-based enterprise applications |
| D-Bean | Acronym | Data Bean — a DTO (Data Transfer Object) class in the X33 framework that holds view-state data for a single screen or data type |
| K-Opticom | Business term | The telecommunications service provider; the system manages customer service orders, surveys, and provisioning workflows |
| Survey (アンケート) | Business term | Customer survey/questionnaire module for collecting feedback or responses as part of service management |
| `enquete_answer_list_list` | Field | Answer response list field — the in-memory list collection of survey answer data beans |
