---

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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW00156SF.FUW00156SF02DBean` |
| Layer | Web View DBean (Data Bean) — Front-end view layer, part of the X33 V-Faces MVC framework |
| Module | `FUW00156SF` (Package: `eo.web.webview.FUW00156SF`) |

## 1. Role

### FUW00156SF02DBean.addListDataInstance()

This method serves as a **lazy factory for survey answer list items** within the K-Opticom web application's service registration and inquiry workflow (FUW00156SF). It is invoked by the X33 V-Faces framework's `X33VListedBeanInterface` contract to dynamically instantiate list data beans when a JSF UI repeat component (such as `<h:dataTable>` or `<ui:repeat>`) requires data elements at render time. The method accepts a string `key` that identifies the data type being requested; it recognizes a single hardcoded key — `アンケート回答リスト` (ENQUETE_ANSWER_LIST, "Survey Answer List") — and, for each call, produces a new instance of `FUW00156SF06DBean` (the survey answer line-item bean). If the target list container (`enquete_answer_list_list`) has not yet been initialized, the method creates it on first access. This follows the **lazy initialization / flyweight factory** pattern: list containers are instantiated only when first needed, and individual bean instances are handed out on demand to feed table-row rendering. The method is called from the parent `FUW00156SFBean.addListDataInstance()`, which acts as the central dispatcher across multiple data-type keys for various survey-related sub-beans.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(String key)"])
    
    START --> CHECK_NULL{key == null?}
    CHECK_NULL -->|Yes| RETURN_NEG1(["Return -1: Null key rejected"])
    CHECK_NULL -->|No| CHECK_ENQUETE{key equals ENQUETE_ANSWER_LIST?}
    
    CHECK_ENQUETE -->|No| RETURN_NEG1
    
    CHECK_ENQUETE -->|Yes| CHECK_NULL_LIST{enquete_answer_list_list == null?}
    CHECK_NULL_LIST -->|Yes| CREATE_LIST["enquete_answer_list_list = new X33VDataTypeList()"]
    CHECK_NULL_LIST -->|No| CREATE_BEAN["tmpBean = new FUW00156SF06DBean()"]
    CREATE_LIST --> CREATE_BEAN
    
    CREATE_BEAN --> ADD_TO_LIST["enquete_answer_list_list.add(tmpBean)"]
    ADD_TO_LIST --> RETURN_INDEX(["Return list.size() - 1"])
    RETURN_INDEX --> END(["End"])
```

**CRITICAL — Constant Resolution:**
- The condition `key.equals("アンケート回答リスト")` resolves to the constant `FUW00156SFConst.ENQUETE_ANSWER_LIST = "アンケート回答リスト"`, which represents the **Survey Answer List** data type — a repeatable list of individual survey responses in the inquiry form.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The data type identifier that determines which list bean class to instantiate. For this method, the only recognized value is `アンケート回答リスト` (ENQUETE_ANSWER_LIST) which signals the caller needs a new row for the **survey answer list** — a repeatable collection of individual customer survey responses rendered in a JSF data table. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `enquete_answer_list_list` | `X33VDataTypeList` | The container list holding all `FUW00156SF06DBean` survey answer instances. Initialized to `null` and lazily created on first `addListDataInstance` call. |

## 4. CRUD Operations / Called Services

This method does not interact with any service components (SC), business business services (CBS), or database tables. It is a purely in-memory bean instantiation and list management operation. No data is read from or written to persistent storage.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| *(none)* | — | — | — | This method performs only in-memory bean creation and list manipulation. No database or service calls. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Bean: `FUW00156SFBean` | `FUW00156SFBean.addListDataInstance(key)` → `super.addListDataInstance(key)` | — (no DB interaction) |

**Notes on the call chain:**
- `FUW00156SFBean` is the parent/umbrella DBean for the entire FUW00156SF screen module. Its `addListDataInstance()` method handles multiple data-type keys (survey answer list, customer mail destinations, mail text templates, etc.). When the key does not match any of the explicitly handled sub-bean types, it delegates to `super.addListDataInstance(key)`, which in turn may route to `FUW00156SF02DBean.addListDataInstance()` (this method) when the `enquete_answer_list_list` list needs new `FUW00156SF06DBean` instances.
- The screen that uses this method chain is accessed via the FUW00156SF web flow module. The X33 framework auto-invokes `addListDataInstance()` when rendering list-based UI components.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(key == null)` (L667)

> Null guard: if the key parameter is null, immediately reject and return -1.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key == null` // Null check on input key |
| 2 | RETURN | `return -1;` // Return -1: no element added |

**Block 2** — ELSE-IF `(key.equals(ENQUETE_ANSWER_LIST))` `[ENQUETE_ANSWER_LIST = "アンケート回答リスト"]` (L672)

> Handle the Survey Answer List data type: lazily initialize the list container if needed, create a new `FUW00156SF06DBean` instance, add it to the list, and return the index of the newly added element.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `key.equals("アンケート回答リスト")` // Match against ENQUETE_ANSWER_LIST constant |

**Block 2.1** — IF `(enquete_answer_list_list == null)` (L673)

> Lazy initialization: the list container has not been created yet; instantiate a new empty `X33VDataTypeList`.

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

**Block 2.2** — EXEC (L676)

> Instantiate the survey answer line-item bean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `FUW00156SF06DBean tmpBean = new FUW00156SF06DBean()` // Create new survey answer bean instance |

**Block 2.3** — EXEC (L678)

> Add the newly created bean to the list.

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

**Block 3** — ELSE (no matching key) (L682)

> Fallback: the key does not match any recognized data type in this DBean. Return -1 to indicate no element was added.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `enquete_answer_list_list` | Field | Survey answer list — an in-memory container holding individual survey answer line-item beans (`FUW00156SF06DBean`) used to render a repeatable list in a JSF data table |
| `enquete_answer_list` | Constant | Survey answer list key — the data-type identifier string `"アンケート回答リスト"` that routes to this method's survey answer handling branch |
| ENQUETE_ANSWER_LIST | Constant | Japanese: アンケート回答リスト — Survey Answer List — the data type name for a repeatable list of customer survey response entries |
| FUW00156SF06DBean | Class | Survey answer line-item bean — holds the data model for a single row in the survey answer list table. Its own fields are defined within the bean class (not visible in this method's source). |
| X33VDataTypeList | Class | Framework generic dynamic list type — an X33 framework list container that holds elements of any data-bean type, used for JSF table data binding |
| X33VListedBeanInterface | Interface | X33 V-Faces listing bean contract — requires the implementing class to provide `addListDataInstance(String key)` so the framework can lazily create list elements |
| JSF | Acronym | JavaServer Faces — Sun/Oracle's component-based UI framework for building web applications. The `<h:dataTable>` and similar components invoke `addListDataInstance` for each row they render. |
| DBean | Acronym | Data Bean — the X33 V-Faces framework pattern for a managed bean that holds screen data state and serves as the model for JSF UI components |
| FUW00156SF | Module | A K-Opticom web application module handling customer survey/inquiry (アンケート) operations — part of the FTTH service management system |
| `X33SException` | Class | X33 framework runtime exception — a checked exception that this method declares in its `throws` clause but does not actively throw in the current logic |

---
