# Business Logic — JKKMainSubKeiJudgeCC.init() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKMainSubKeiJudgeCC` |
| Layer | CC / Common Component (Package: `com.fujitsu.futurity.bp.custom.common`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKMainSubKeiJudgeCC.init()

The `init()` method serves as the entry-point initialization routine for the Main/Sub Service Category Switching (主従切替) processing pipeline within the K-Opticom customer base system (eo顧客基幹システム). It is a private bootstrap method that prepares the internal state and error-handling context before any actual switching logic runs.

The method follows the **Lazy Initialization (double-check-when-needed)** pattern for the mapper field — if `this.mapper` has not yet been instantiated, it creates a fresh `JKKMainSubKeiJudgeMapperCC` instance. This ensures the mapper is available for downstream mapping operations without incurring unnecessary construction cost when the method is called multiple times or in contexts where the mapper was already provided.

Additionally, it initializes the error-handling collection in the request parameter's control map. By registering an empty `ArrayList<Object>` at the `SCControlMapKeys.ERROR_INFO` key, it establishes a clean error slate that downstream processing steps (e.g., validation, CBS invocation) can populate with error messages. This is a critical prerequisite for the error-display mechanism used by the screen tier.

Within the larger system, `init()` is the first step invoked by `runMskj()` — the public method that performs Main/Sub Service Category Switching (主従切替処理) using the service contract number from request parameters. It is a shared utility invoked internally; it does not have screen/batch entry points of its own.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["init(params, fixedText)"])
    CHECK_MAPPER{"mapper == null?"}
    INIT_MAPPER["mapper = new JKKMainSubKeiJudgeMapperCC()"]
    INIT_ERROR["param.setControlMapData(ERROR_INFO, new ArrayList())"]
    END_NODE(["Return / Next"])

    START --> CHECK_MAPPER
    CHECK_MAPPER -->|true| INIT_MAPPER
    INIT_MAPPER --> INIT_ERROR
    CHECK_MAPPER -->|false| INIT_ERROR
    INIT_ERROR --> END_NODE
```

**CRITICAL — Constant Resolution:**

- `SCControlMapKeys.ERROR_INFO` — Key used within the control map to identify the error information list. When `param.setControlMapData(ERROR_INFO, new ArrayList<Object>())` is called, an empty list of error objects is registered so that any downstream validation or CBS processing can append error messages under this same key for later screen rendering.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries the model group data and the control map. The control map is a key-value structure used to pass screen-related state (such as error lists, field values, and metadata) between the screen tier, common components, and service components. In this method, the control map is initialized with an empty error list at the `ERROR_INFO` key. |
| 2 | `fixedText` | `String` | A user-defined arbitrary text string. In this method it is received but not used — it is likely reserved for future extensibility or passed through by the caller for logging/debugging purposes. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.mapper` | `JKKMainSubKeiJudgeMapperCC` | The mapper group used by this common component for data mapping between entities and request parameters. It is lazily initialized here if not already set. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | `JKKMainSubKeiJudgeMapperCC.<init>()` | — | — | Constructor call — creates a new instance of the Main/Sub Service Category Switching mapper. No database operation; this is a pure in-memory object instantiation. |
| EXEC | `param.setControlMapData(String key, Object data)` | — | — | Sets a key-value pair in the request parameter's control map. Registers an empty `ArrayList` under the `ERROR_INFO` key to serve as the error message container for downstream processing. |

**Note:** This method performs no direct database CRUD operations (no SC code invocations, no CBS calls). It is purely a setup/initialization method.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

Direct callers found: 1 method.

This method is private and is called exclusively by `runMskj()` within the same class. `runMskj()` is the public entry point for the Main/Sub Service Category Switching (主従切替) processing, which takes a service contract number and performs switching logic.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKMainSubKeiJudgeCC | `runMskj(handle, param, fixedText)` -> `init(param, fixedText)` | No terminal operations (initialization only) |

**Call chain explanation:**

1. **CC `runMskj()`** (line 70) — The public method that begins the Main/Sub Service Category Switching processing. It immediately delegates to `init()` at line 93 (`init(param, fixedText);`) to prepare the mapper and error list before proceeding with the actual switching logic. No external entry points (screens or batches) were found within 8 hops — the method is an internal bootstrap step.

## 6. Per-Branch Detail Blocks

> The `init()` method contains a single conditional block (mapper lazy initialization) followed by a sequential processing step (error list initialization).

**Block 1** — IF `(null == this.mapper)` (L50)

> Business description: Lazy initialization of the mapper. If the mapper field has not been set (null), a new `JKKMainSubKeiJudgeMapperCC` instance is created. This ensures that downstream mapping operations have a valid mapper without requiring the caller to instantiate it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.mapper = new JKKMainSubKeiJudgeMapperCC()` // マッパーの初期化 (Mapper initialization) |

**Block 2** — SEQUENTIAL (L55)

> Business description: Initialize the error information list in the control map. A new empty `ArrayList` is registered at the `ERROR_INFO` key so that any downstream processing can populate error messages for screen display.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, new ArrayList<Object>())` // コントロールマップのエラー情報を初期化 (Initialize error information in control map) |

**Block 3** — RETURN (L56)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `void` // Method returns; next step is the caller (`runMskj`) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `JKKMainSubKeiJudgeCC` | Class | Main/Sub Service Category Switching Common Component — the common component class responsible for switching logic between main and sub service categories. |
| 主従切替 (Shujū Settai) | Business term | Main/Sub Service Category Switching — the business operation of switching or differentiating between main (primary) and sub (secondary) service contract categories. |
| eo顧客基幹システム | Business term | eo Customer Base System — the core customer management system at K-Opticom for managing service contracts, orders, and customer data. |
| `IRequestParameterReadWrite` | Interface | Request parameter read/write interface — a data structure that carries model group data and control map key-value pairs between screen, common component, and service component tiers. |
| `mapper` / マッパー | Field | Mapper group — a collection of mapping objects (`JKKMainSubKeiJudgeMapperCC`) used to convert between entity objects and request parameter data. |
| `JKKMainSubKeiJudgeMapperCC` | Class | Main/Sub Service Category Switching Mapper Common Component — the mapper class that handles data mapping specific to the switching processing. |
| コントロールマップ (Kontorō Mappu) | Business term | Control Map — a key-value map within the request parameter used to pass screen-level metadata (such as error lists, field labels, and display hints) between tiers. |
| `ERROR_INFO` | Constant | Error Information — the control map key used to store a list of error messages. Downstream processing appends error entries to this list for screen rendering. |
| `SCControlMapKeys` | Class | SC (Service Component) Control Map Keys — a constant class defining standard keys used in the control map, including `ERROR_INFO`. |
| `fixedText` | Field | User-defined arbitrary text string — freeform text passed through by the caller, potentially for logging, tracing, or future extensibility. |
| `IRequestParameterReadWrite` | Interface | Request parameter read/write interface — part of the Futurity/BPM framework for data exchange between the presentation tier and business logic tier. |
