---
title: Business Logic — KKW01027SF01DBean.addListDataInstance() [21 LOC]
tags:
  - DD
---

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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA15001SF.KKW01027SF01DBean` |
| Layer | Web Presentation / Data Bean (Controller-adjacent — X33 framework view data bean) |
| Module | `KKA15001SF` (Package: `eo.web.webview.KKA15001SF`) |

## 1. Role

### KKW01027SF01DBean.addListDataInstance()

This method is a **list item instance generator** within the K-Opticom web presentation framework (X33). It serves as a factory that creates and appends typed data bean instances into the appropriate list field of the `KKW01027SF01DBean` class, based on a string key that identifies which business list item is being requested.

The method handles **customer contract change order screens** — specifically, it supports initializing lists of "discretionary change reason codes" (`ido_rsn_cd_list`). These reason codes are used when customers submit modifications to existing service contracts, and each entry in the list represents one reason code that can be assigned to a line item.

It implements a **dispatch/routing pattern**: the method receives a key string representing a named list item, and branches to instantiate the appropriate typed data bean (`X33VDataTypeStringBean`) for that list. When the requested list does not yet exist, it lazily initializes the list with a new `X33VDataTypeList`. This is a shared utility method called from the parent bean (`KKW01027SFBean`) during screen data preparation, specifically when constructing list-type view data for contract change order forms.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(key)"])
    COND_NULL{"key == null"}
    PROC_RETURN_NULL(["return -1"])
    COND_RSN{"key equals \"異動理由コード\" (Discretionary Change Reason Code)"}
    PROC_CHECK_LIST{"ido_rsn_cd_list == null"}
    PROC_INIT_LIST["ido_rsn_cd_list = new X33VDataTypeList()"]
    PROC_NEW_BEAN["X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean()"]
    PROC_ADD_LIST["ido_rsn_cd_list.add(tmpBean)"]
    PROC_RETURN_INDEX["return ido_rsn_cd_list.size() - 1"]
    PROC_RETURN_DEFAULT(["return -1"])

    START --> COND_NULL
    COND_NULL -->|true| PROC_RETURN_NULL
    COND_NULL -->|false| COND_RSN
    COND_RSN -->|true| PROC_CHECK_LIST
    COND_RSN -->|false| PROC_RETURN_DEFAULT
    PROC_CHECK_LIST -->|true| PROC_INIT_LIST
    PROC_CHECK_LIST -->|false| PROC_NEW_BEAN
    PROC_INIT_LIST --> PROC_NEW_BEAN
    PROC_NEW_BEAN --> PROC_ADD_LIST
    PROC_ADD_LIST --> PROC_RETURN_INDEX
    PROC_RETURN_NULL --> END1(["Return -1: key is null"])
    PROC_RETURN_DEFAULT --> END2(["Return -1: key not matched"])
    PROC_RETURN_INDEX --> END3(["Return index: element appended"])
```

**Block descriptions:**
- **Null guard (L618):** If `key` is null, immediately return `-1` without further processing. This is a null-safety check.
- **Key routing (L621):** Checks if the key matches the hardcoded string `"異動理由コード"` (Discretionary Change Reason Code). This is the only active branch in this method — other list types are expected to be handled by overriding classes or the parent class.
- **List initialization (L622–624):** If the `ido_rsn_cd_list` field is null (first time access), lazily creates a new `X33VDataTypeList` instance.
- **Bean instantiation and append (L625–628):** Creates a new `X33VDataTypeStringBean` (the data type bean for string values), appends it to the list, and returns the index of the newly added element (`size() - 1`).
- **Default return (L629):** For any key that does not match a recognized list name, returns `-1`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The list item name that identifies which typed data bean list should be instantiated. For this method, the value `"異動理由コード"` (Discretionary Change Reason Code) triggers creation of a reason code entry within the contract change order form. Other values cause a `-1` return. |
| 2 | `ido_rsn_cd_list` (instance field) | `X33VDataTypeList` | The internal list field holding discretionary change reason code entries. Each element is a `X33VDataTypeStringBean` representing a single reason code value. Lazily initialized on first access. |

## 4. CRUD Operations / Called Services

This method performs **no database operations, no SC/CBS calls, and no external service invocations**. It is a pure data bean factory that creates in-memory list instances for the X33 view framework.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| N/A | `addListDataInstance()` | — | — | No persistence operation — this is a presentation-layer data bean factory that creates view-model list entries in memory. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW01027SF (KKW01027SFBean) | `KKW01027SFBean` (parent bean) → `KKW01027SF01DBean.addListDataInstance` | N/A (in-memory bean factory) |
| 2 | Inherited by FUW* screens | `FUW00912SFBean` (extends base) → `super.addListDataInstance` → `KKW01027SF01DBean.addListDataInstance` | N/A |

**Notes on callers:**
- The primary caller is the parent bean `KKW01027SFBean` within the `KKA15001SF` module, which handles the **Contract Change Order Information Input** screen (KKW01027SF).
- Multiple `FUW*` screens (e.g., `FUW00912SFBean`, `FUW00926SFBean`, `FUW00964SFBean`, etc.) also call this method via `super.addListDataInstance(key)` delegation, typically as part of a shared base bean hierarchy. These screens generally handle customer contract change, modification, and inquiry operations.
- This method is part of a standard X33 data bean pattern where the list-type items are lazily initialized through this factory method.

## 6. Per-Branch Detail Blocks

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

> Null guard: prevents NullPointerException and returns early if no key is provided.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Returns -1 when key is null [-> NO MATCH] |

**Block 2** — [ELSE-IF] `(key.equals("異動理由コード"))` [CONSTANT: "異動理由コード" = "Discretionary Change Reason Code"] (L621)

> Checks if the key matches the hardcoded string for the discretionary change reason code list. This is the only active business branch — it handles the case where a new reason code entry needs to be added to a contract change order form.

**Block 2.1** — [IF] `(ido_rsn_cd_list == null)` (L622)

> Lazy initialization: if the reason code list has not yet been created, instantiate it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ido_rsn_cd_list = new X33VDataTypeList();` // Creates new empty list for reason codes [-> LIST INITIALIZATION] |

**Block 2.2** — [PROCESSING] (L625–628)

> Creates a typed string bean, appends it to the list, and returns the new element's index.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // Instantiates typed data bean for the list item // (データタイプビーン型で指定したデータタイプビーンのインスタンスを生成する。) |
| 2 | EXEC | `ido_rsn_cd_list.add(tmpBean);` // Appends the new bean to the reason code list |
| 3 | RETURN | `return ido_rsn_cd_list.size() - 1;` // Returns the index of the newly added element |

**Block 3** — [ELSE / FALLTHROUGH] (L629)

> Default return for any unrecognized key. Returns `-1` to indicate that the requested list item is not supported by this bean class.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `key` | Parameter | List item name — identifies which typed data bean list should be instantiated. In this method, `"異動理由コード"` is the only supported value. |
| `ido_rsn_cd_list` | Field | Discretionary change reason code list — an `X33VDataTypeList` holding reason code entries for contract change orders. Each entry is a `X33VDataTypeStringBean`. |
| `X33VDataTypeList` | Type | X33 framework generic list type — a typed collection used to store multiple instances of data bean types for repeatable form fields. |
| `X33VDataTypeStringBean` | Type | X33 framework string data type bean — a wrapper bean for string values used within X33 list-type data structures. |
| `X33VDataTypeBeanInterface` | Interface | X33 framework contract — marks a class as a valid data type bean that can be used within X33 view data structures. |
| `X33VListedBeanInterface` | Interface | X33 framework contract — marks a class as a bean that participates in list operations (e.g., `listKoumokuIds`). |
| 異動理由コード (ido_rsn_cd) | Field | Discretionary Change Reason Code — the reason a service contract modification was requested. Stored as a string in each list element. |
| KKW01027SF01DBean | Class | Contract Change Order Data Bean — the X33 view data bean for screen KKW01027SF, handling customer contract change order form data. |
| KKA15001SF | Module | Contract Change Order module — the X33 screen module for contract change order information input and processing. |
| X33SException | Exception | X33 framework exception type — thrown by data bean operations. |
| K-Opticom | Business term | K-Opticom — the telecommunications service provider. This application is part of K-Opticom's customer contract management system. |
