# Business Logic — KKW01023SF02DBean.typeModelData() [65 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW01023SF.KKW01023SF02DBean` |
| Layer | Utility / Data Bean (Package: `eo.web.webview.KKW01023SF`) |
| Module | `KKW01023SF` (Package: `eo.web.webview.KKW01023SF`) |

## 1. Role

### KKW01023SF02DBean.typeModelData()

This method serves as the **data-type resolver** for UI-bound fields within the K-Opticom contract management screen (`KKW01023SF`). It implements the `X33VDataTypeBeanInterface.typeModelData(String key, String subkey)` contract, which is part of the X33 web framework's generic data binding mechanism. When the framework needs to know the Java type of a particular UI field component — for example, whether a field's "value" should be rendered as a `String` or a boolean input — it delegates to this method to return the appropriate `Class<?>` descriptor.

The method handles **four contract-related data categories**: Item Count ("番号／件数", item ID: `no_cnt`), Target Contract Identifier Code Name ("対象契約識別コード名称", item ID: `tg_kei_skbt_cd_nm`), Target Contract Number ("対象契約番号", item ID: `tgt_kei_no`), and Target Service Name ("対象サービス名称", item ID: `tgt_svc_nm`). For each category, it dispatches to one of three subkey branches: `"value"` (returns `String.class`), `"enable"` (returns `Boolean.class`), or `"state"` (returns `String.class`, representing the UI status — see Section 2 note below).

The design pattern employed is a **routing/dispatch** pattern: the method acts as a pure lookup table with no side effects, making it safe to invoke from the framework at any time during view rendering. It plays a supporting role within the larger X33 view component lifecycle — it is not called directly by screen controllers but is instead resolved dynamically via reflection by the X33 framework's type inference machinery.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData key, subkey"])
    NULL_CHECK["key == null || subkey == null ?"]
    RETURN_NULL(["return null"])
    SEARCH_SLASH["int separaterPoint = key.indexOf('/')"]
    CHECK_KEY1["key.equals('番号／件数') ?"]
    CHECK_SUBVALUE1{"subkey.equalsIgnoreCase('value') ?"}
    CHECK_SUBENABLE1{"subkey.equalsIgnoreCase('enable') ?"}
    CHECK_SUBSTATE1{"subkey.equalsIgnoreCase('state') ?"}
    RETURN_STRING1(["return String.class"])
    RETURN_BOOLEAN1(["return Boolean.class"])
    CHECK_KEY2["key.equals('対象契約識別コード名称') ?"]
    CHECK_SUBVALUE2{"subkey.equalsIgnoreCase('value') ?"}
    CHECK_SUBENABLE2{"subkey.equalsIgnoreCase('enable') ?"}
    CHECK_SUBSTATE2{"subkey.equalsIgnoreCase('state') ?"}
    CHECK_KEY3["key.equals('対象契約番号') ?"]
    CHECK_SUBVALUE3{"subkey.equalsIgnoreCase('value') ?"}
    CHECK_SUBENABLE3{"subkey.equalsIgnoreCase('enable') ?"}
    CHECK_SUBSTATE3{"subkey.equalsIgnoreCase('state') ?"}
    CHECK_KEY4["key.equals('対象サービス名称') ?"]
    CHECK_SUBVALUE4{"subkey.equalsIgnoreCase('value') ?"}
    CHECK_SUBENABLE4{"subkey.equalsIgnoreCase('enable') ?"}
    CHECK_SUBSTATE4{"subkey.equalsIgnoreCase('state') ?"}
    RETURN_FALLBACK(["return null"])

    START --> NULL_CHECK
    NULL_CHECK -->|Yes| RETURN_NULL
    NULL_CHECK -->|No| SEARCH_SLASH
    SEARCH_SLASH --> CHECK_KEY1
    CHECK_KEY1 -->|Yes| CHECK_SUBVALUE1
    CHECK_KEY1 -->|No| CHECK_KEY2
    CHECK_SUBVALUE1 -->|Yes| RETURN_STRING1
    CHECK_SUBVALUE1 -->|No| CHECK_SUBENABLE1
    CHECK_SUBENABLE1 -->|Yes| RETURN_BOOLEAN1
    CHECK_SUBENABLE1 -->|No| CHECK_SUBSTATE1
    CHECK_SUBSTATE1 -->|Yes| RETURN_STRING1
    CHECK_SUBSTATE1 -->|No| CHECK_KEY2
    CHECK_KEY2 -->|Yes| CHECK_SUBVALUE2
    CHECK_KEY2 -->|No| CHECK_KEY3
    CHECK_SUBVALUE2 -->|Yes| RETURN_STRING1
    CHECK_SUBVALUE2 -->|No| CHECK_SUBENABLE2
    CHECK_SUBENABLE2 -->|Yes| RETURN_BOOLEAN1
    CHECK_SUBENABLE2 -->|No| CHECK_SUBSTATE2
    CHECK_SUBSTATE2 -->|Yes| RETURN_STRING1
    CHECK_SUBSTATE2 -->|No| CHECK_KEY3
    CHECK_KEY3 -->|Yes| CHECK_SUBVALUE3
    CHECK_KEY3 -->|No| CHECK_KEY4
    CHECK_SUBVALUE3 -->|Yes| RETURN_STRING1
    CHECK_SUBVALUE3 -->|No| CHECK_SUBENABLE3
    CHECK_SUBENABLE3 -->|Yes| RETURN_BOOLEAN1
    CHECK_SUBENABLE3 -->|No| CHECK_SUBSTATE3
    CHECK_SUBSTATE3 -->|Yes| RETURN_STRING1
    CHECK_SUBSTATE3 -->|No| CHECK_KEY4
    CHECK_KEY4 -->|Yes| CHECK_SUBVALUE4
    CHECK_KEY4 -->|No| RETURN_FALLBACK
    CHECK_SUBVALUE4 -->|Yes| RETURN_STRING1
    CHECK_SUBVALUE4 -->|No| CHECK_SUBENABLE4
    CHECK_SUBENABLE4 -->|Yes| RETURN_BOOLEAN1
    CHECK_SUBENABLE4 -->|No| CHECK_SUBSTATE4
    CHECK_SUBSTATE4 -->|Yes| RETURN_STRING1
    CHECK_SUBSTATE4 -->|No| RETURN_FALLBACK
```

**Branch Summary:**

| Branch | Key (Business Meaning) | Subkey | Return Type |
|--------|----------------------|--------|-------------|
| Branch 1 | "番号／件数" — Item Count (item ID: `no_cnt`) | `"value"` | `String.class` |
| Branch 2 | same | `"enable"` | `Boolean.class` |
| Branch 3 | same | `"state"` | `String.class` |
| Branch 4 | "対象契約識別コード名称" — Target Contract Identifier Code Name (item ID: `tg_kei_skbt_cd_nm`) | `"value"` | `String.class` |
| Branch 5 | same | `"enable"` | `Boolean.class` |
| Branch 6 | same | `"state"` | `String.class` |
| Branch 7 | "対象契約番号" — Target Contract Number (item ID: `tgt_kei_no`) | `"value"` | `String.class` |
| Branch 8 | same | `"enable"` | `Boolean.class` |
| Branch 9 | same | `"state"` | `String.class` |
| Branch 10 | "対象サービス名称" — Target Service Name (item ID: `tgt_svc_nm`) | `"value"` | `String.class` |
| Branch 11 | same | `"enable"` | `Boolean.class` |
| Branch 12 | same | `"state"` | `String.class` |
| Fallback | — | — | `null` |

**Note on "state" subkey:** Each branch's `"state"` subkey returns `String.class`. The Japanese comment states: "If subkey is 'state', return the status." This provides the framework with the type for the UI state property of each field, which is used to track display states such as enabled, disabled, or error.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The field name (項目名) that identifies which UI-bound data category is being queried. Acceptable values are: `"番号／件数"` (Item Count), `"対象契約識別コード名称"` (Target Contract Identifier Code Name), `"対象契約番号"` (Target Contract Number), or `"対象サービス名称"` (Target Service Name). An unknown key causes the method to fall through and return `null`. |
| 2 | `subkey` | `String` | The sub-property name within the field category. Valid values are `"value"` (the display value), `"enable"` (whether the field is editable/enabled), or `"state"` (the current UI status). The comparison is case-insensitive (`equalsIgnoreCase`). |

**Instance fields / external state:** This method is **pure** — it reads no instance fields and calls no external services. It performs only string comparisons and returns Java type references.

## 4. CRUD Operations / Called Services

This method performs no CRUD operations. It is a pure dispatch/lookup method with no database access, no service component calls, and no persistence side effects.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No database or service calls; pure type resolution. |

## 5. Dependency Trace

`typeModelData` is **not directly invoked** by any Java source file in the codebase. Instead, it is part of the `X33VDataTypeBeanInterface` contract implemented by `KKW01023SF02DBean`. The X33 web framework resolves the method dynamically via reflection during view rendering when it needs to determine the data type of a bound field component.

The `KKW01023SF02DBean` class is instantiated and used indirectly through `KKW01023SFBean` via the `listKoumokuIds()` delegation path:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW01023SF (via KKW01023SFBean) | `KKW01023SFBean.listKoumokuIds(key)` → framework type binding → `KKW01023SF02DBean.typeModelData(key, subkey)` | None — pure type resolver |
| 2 | Screen:KKW01023SF (via KKW01023SFBean) | `KKW01023SFBean` creates `new KKW01023SF02DBean()` → framework invokes `typeModelData` on each field | None — pure type resolver |

The entry point is the `KKW01023SF` screen, which uses the X33 framework's generic type binding. When the bean's `listKoumokuIds` method returns metadata for data-type-view fields (データタイプビューン型項目), the X33 framework calls `typeModelData` to determine the Java type for each sub-component.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `key == null || subkey == null` (L399)

> Early-exit guard: if either parameter is null, the method cannot resolve a type and returns `null` immediately.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int separaterPoint = key.indexOf("/")` // Compute separator index for future extensibility [L401] |
| 2 | RETURN | `return null;` // key or subkey is null, cannot resolve [L400] |

**Block 2** — [IF] `key.equals("番号／件数")` (L404) — **Item Count** (item ID: `no_cnt`)

> This is the first data category. The field tracks item counts with three sub-properties: display value, enabled state, and UI state.

**Block 2.1** — [IF] `subkey.equalsIgnoreCase("value")` (L405)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The display value of the item count is a string |

**Block 2.2** — [ELSE-IF] `subkey.equalsIgnoreCase("enable")` (L408)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Boolean.class;` // The enabled/disabled toggle is a boolean |

**Block 2.3** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L411) — `subkeyが"state"の場合、ステータスを返す` (If subkey is "state", return the status)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The UI state (display status) is a string |

**Block 3** — [ELSE-IF] `key.equals("対象契約識別コード名称")` (L417) — **Target Contract Identifier Code Name** (item ID: `tg_kei_skbt_cd_nm`)

> Second data category. The field identifies the code name of the target contract's classification.

**Block 3.1** — [IF] `subkey.equalsIgnoreCase("value")` (L418)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The code name display value is a string |

**Block 3.2** — [ELSE-IF] `subkey.equalsIgnoreCase("enable")` (L421)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Boolean.class;` // The enabled/disabled toggle is a boolean |

**Block 3.3** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L424) — `subkeyが"state"の場合、ステータスを返す` (If subkey is "state", return the status)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The UI state (display status) is a string |

**Block 4** — [ELSE-IF] `key.equals("対象契約番号")` (L430) — **Target Contract Number** (item ID: `tgt_kei_no`)

> Third data category. The field holds the contract number identifier for the target.

**Block 4.1** — [IF] `subkey.equalsIgnoreCase("value")` (L431)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The contract number display value is a string |

**Block 4.2** — [ELSE-IF] `subkey.equalsIgnoreCase("enable")` (L434)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Boolean.class;` // The enabled/disabled toggle is a boolean |

**Block 4.3** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L437) — `subkeyが"state"の場合、ステータスを返す` (If subkey is "state", return the status)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The UI state (display status) is a string |

**Block 5** — [ELSE-IF] `key.equals("対象サービス名称")` (L443) — **Target Service Name** (item ID: `tgt_svc_nm`)

> Fourth data category. The field holds the name of the target service.

**Block 5.1** — [IF] `subkey.equalsIgnoreCase("value")` (L444)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The service name display value is a string |

**Block 5.2** — [ELSE-IF] `subkey.equalsIgnoreCase("enable")` (L447)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Boolean.class;` // The enabled/disabled toggle is a boolean |

**Block 5.3** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L450) — `subkeyが"state"の場合、ステータスを返す` (If subkey is "state", return the status)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // The UI state (display status) is a string |

**Block 6** — [FALLBACK] no matching key (L453)

> No matching property was found in any category. The Japanese comment states: "プロパティが存在しない場合は、nullを返す" (If no property exists, return null).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // No matching key found; framework should handle null gracefully [L454] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `番号／件数` | Field | Item Count — the number of items in a list or record set; item ID: `no_cnt` |
| `対象契約識別コード名称` | Field | Target Contract Identifier Code Name — the classification code name identifying the type of contract; item ID: `tg_kei_skbt_cd_nm` |
| `対象契約番号` | Field | Target Contract Number — the unique contract number identifier; item ID: `tgt_kei_no` |
| `対象サービス名称` | Field | Target Service Name — the name of the service being contracted or managed; item ID: `tgt_svc_nm` |
| `value` | Subkey | The display value of a UI-bound field component |
| `enable` | Subkey | Whether a UI-bound field is enabled (editable) or disabled |
| `state` | Subkey | The current UI status of a field (e.g., enabled, disabled, error state) — displayed as a string type |
| X33VDataTypeBeanInterface | Interface | X33 framework interface for data-type-bound beans; defines `typeModelData(String key, String subkey)` for runtime type resolution |
| X33VListedBeanInterface | Interface | X33 framework interface for list-capable beans; defines `listKoumokuIds(String key)` for metadata retrieval |
| X33 Framework | Technology | Fujitsu Futurity X33 — a JavaServer Faces (JSF) web application framework used in the K-Opticom system for view component binding and lifecycle management |
| KKW01023SF | Module | K-Opticom screen module for contract management (KKW = K-Opticom Web); the specific sub-module `KKW01023SF02DBean` handles data-type-bound field metadata |
| 項目名 (koumoku-mei) | Field | Field name / Item name — the business identifier used to look up metadata for a UI-bound field |
| サブキー (sabukii) | Field | Sub-key — the sub-property identifier within a field category (value, enable, state) |
| Bean (DBean) | Pattern | Data-bound Java bean — a Java class implementing X33 framework interfaces that provides metadata and data for JSF view rendering |
