
# Business Logic — MsgEditer.set() [7 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.MsgEditer` |
| Layer | Service Component (CC — Common Component / CBS Parameter Builder) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### MsgEditer.set()

`MsgEditer.set()` is a utility method that safely populates a `CAANMsg` (Centralized Application ANd Message) object, which is the inter-service communication envelope used to exchange data between Screen Components (SC) and Service Components (CBS) in the Fujitsu Futurity BP (Business Platform) system. Its core business responsibility is **parameter serialization with null-aware semantics**: when the caller passes a `null` or empty string (`""`) as the value, the method delegates to `setRaw(..., true)` which stores the key as a null field in the message via `msg.setNull(key)`; when a non-null, non-empty value is passed, it stores the actual value via `msg.set(key, value)`. This behavior ensures downstream CBS methods receive consistent null representation regardless of whether the calling code passed an actual `null` reference or a blank string — both are normalized to a message-level null. The method is part of the `MsgEditer` helper class embedded in `JKKWribSvcKeiOperateCC`, a wire service contract modification batch processing component, and serves as the standard parameter-setting pattern for all CBS invocations that this component orchestrates. Its role in the larger system is a **shared CBS parameter builder** — it is invoked by multiple CBS-invoking methods in `JKKWribSvcKeiOperateCC`, `JKKMineoSetPlanWribCC`, and reflection-based dynamic dispatch in `KKW00101SFBean`, making it a foundational building block for inter-service communication throughout the application.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["set(msg, key, value)"])

    START --> COND1{"value is null
or empty string"}

    COND1 -->|true: null or ""| SETNULL["setRaw(msg, key, value, true)
isNull=true"]
    COND1 -->|false: non-null,
non-empty| SETVALUE["setRaw(msg, key, value, false)
isNull=false"]

    SETNULL --> CALL_NULL["msg.setNull(key)"]
    SETVALUE --> CALL_SET["msg.set(key, value)"]

    CALL_NULL --> END_NODE(["Return"])
    CALL_SET --> END_NODE
```

**Logic summary:**

1. **Check if value is null or empty string** — The method evaluates `null == value || "".equals(value)`. If the value is either `null` or an empty string, it normalizes this to a "null" state in the message.
2. **Branch true — set as null** — Calls `setRaw(msg, key, value, true)` with the `isNull` flag set to `true`. Inside `setRaw`, this triggers `msg.setNull(key)`, which marks the field as null in the `CAANMsg` schema. This is the business-semantic way of saying "this parameter has no value" — downstream CBS methods receive the key as a missing/null value.
3. **Branch false — set the actual value** — Calls `setRaw(msg, key, value, false)` with the `isNull` flag set to `false`. Inside `setRaw`, this triggers `msg.set(key, value)`, which stores the actual value into the `CAANMsg` at the given key.
4. **Return** — The method returns void; the side effect is the mutation of the `msg` object.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msg` | `CAANMsg` | The CBS parameter message envelope. This is a strongly-typed message object built on top of a schema definition (e.g., `EKK0481B005CBSMsg`). It carries all input parameters from a Screen/Batch component to a CBS method for inter-service communication. The schema defines which keys are valid for the message. |
| 2 | `key` | `String` | The parameter key within the `CAANMsg` schema. Each key maps to a specific business data field expected by the target CBS method. Examples include `KEY_WRIB_SVC_KEI_NO` (wire service contract number), `KEY_SVC_KEI_NO` (service contract number), `KEY_DCHSKMST_NO` (change service master number), `KEY_WRIB_SVC_CD` (wire service code), and `KEY_INTR_CD` (interest code). The key must match a schema-defined field. |
| 3 | `value` | `Object` | The business data value to assign to the key. Typically a `String` representing identifiers, codes, or free-form text. When `null` or an empty string (`""`), the method treats it as "no value provided" and stores the key as null in the message, ensuring the CBS method can distinguish between "not provided" and "provided with empty string." |

**External state / instance fields read:** None. This is a pure static utility method with no side effects other than mutating the `msg` object passed in.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `setRaw` | - (internal utility) | `CAANMsg` | Delegates to `setRaw(msg, key, value, isNull)` which mutates the `CAANMsg` object — either calling `msg.setNull(key)` (when value is null/empty) or `msg.set(key, value)` (when value is present). This is the parameter-setting operation that writes data into the CBS request envelope. |

**Classification rationale:**

- **U (Update)**: `setRaw` updates the `CAANMsg` object in-place by setting a field value or marking it as null. It does not create a new entity, query a database, or delete data. It is a pure state-mutation operation on the message envelope.

No database or SC/CBS layer calls are made. This method operates entirely at the message-building layer, constructing CBS request parameters before the actual CBS invocation occurs (which happens in the caller).

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|----------------------------------|-------------------------------|
| 1 | Batch:JKKWribSvcKeiOperateCC | `JKKWribSvcKeiOperateCC.processWireSvcKei` → `MsgEditer.set(msg, KEY_WRIB_SVC_KEI_NO, tgKeiNo)` | `setRaw [U] CAANMsg` |
| 2 | Batch:JKKWribSvcKeiOperateCC | `JKKWribSvcKeiOperateCC.processWireSvcKei` → `MsgEditer.set(msg, KEY_SVC_KEI_NO, sKeiNo)` | `setRaw [U] CAANMsg` |
| 3 | Batch:JKKWribSvcKeiOperateCC | `JKKWribSvcKeiOperateCC.processChangeSvcMst` → `MsgEditer.set(msg, KEY_DCHSKMST_NO, tgKeiNo)` | `setRaw [U] CAANMsg` |
| 4 | Batch:JKKWribSvcKeiOperateCC | `JKKWribSvcKeiOperateCC.processChangeSvcMst` → `MsgEditer.set(msg, KEY_SVC_KEI_NO, sKeiNo)` | `setRaw [U] CAANMsg` |
| 5 | Batch:JKKWribSvcKeiOperateCC | `JKKWribSvcKeiOperateCC.processInterestCode` → `MsgEditer.set(msg, KEY_INTR_CD, intrCd)` | `setRaw [U] CAANMsg` |
| 6 | Batch:JKKWribSvcKeiOperateCC | `JKKWribSvcKeiOperateCC.processWireSvcCode` → `MsgEditer.set(msg, KEY_WRIB_SVC_CD, wribSvcCd)` | `setRaw [U] CAANMsg` |
| 7 | Batch:JKKMineoSetPlanWribCC | `JKKMineoSetPlanWribCC.execute` → `MsgEditer.set(msg, KEY_WORK_PARAM_ID, ...)` | `setRaw [U] CAANMsg` |
| 8 | Batch:JKKMineoSetPlanWribCC | `JKKMineoSetPlanWribCC.execute` → `MsgEditer.set(msg, KEY_WRIB_SVC_CD, ...)` | `setRaw [U] CAANMsg` |
| 9 | Batch:JKKMineoSetPlanWribCC | `JKKMineoSetPlanWribCC.execute` → `MsgEditer.set(msg, KEY_RSV_APLY_YMD, opeDate)` | `setRaw [U] CAANMsg` |
| 10 | Dynamic:KKW00101SFBean | `KKW00101SFBean` via reflection (`getMethod` / `invoke`) → `MsgEditer.set(msg, field, val)` | `setRaw [U] CAANMsg` |

_Detected 10 unique call sites across 3 caller classes, with one additional dynamic reflection-based caller._

**Summary:** The `MsgEditer.set()` method is a widely-used utility invoked from both batch processing components (`JKKWribSvcKeiOperateCC`, `JKKMineoSetPlanWribCC`) and dynamic dispatch code (`KKW00101SFBean`). It is never called by a user-facing screen directly — instead, screens invoke CBS methods through their SC, and those SCs use `MsgEditer.set()` to build the CBS parameter envelope before the CBS invocation.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(null == value || "".equals(value))` (L16577)

> Determine if the value should be treated as "null" in the CBS message. This condition normalizes both Java `null` references and empty strings into a single semantic meaning: the parameter is not provided.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (null == value || "".equals(value))` |
| 2 | BRANCH-T | `setRaw(msg, key, value, true)` → calls `msg.setNull(key)` |
| 3 | BRANCH-F | `setRaw(msg, key, value, false)` → calls `msg.set(key, value)` |

**Block 1.1** — [ELSE-IF true branch] `null == value` (L16578)

> The value is `null`. The method signals to `setRaw` that the field should be treated as a null value by passing `isNull=true`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setRaw(msg, key, value, true)` |
| 2 | SET | `isNull = true` (implicit in method signature) |
| 3 | CALL | `msg.setNull(key)` (inside `setRaw`) |

**Block 1.2** — [ELSE-IF OR branch] `"".equals(value)` (L16578)

> The value is an empty string (`""`). The method normalizes empty strings to null semantics — this ensures that callers who pass `""` instead of `null` still get the field treated as "not provided" in the CBS message.

| # | Type | Code |
|---|------|------|
| 1 | COND | `"".equals(value)` |
| 2 | CALL | `setRaw(msg, key, value, true)` (same branch as null) |
| 3 | SET | `isNull = true` (implicit in method signature) |
| 4 | CALL | `msg.setNull(key)` (inside `setRaw`) |

**Block 1.3** — [ELSE false branch] value is non-null and non-empty (L16580)

> The value is a concrete, non-empty value. The method passes it through directly to the message.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setRaw(msg, key, value, false)` |
| 2 | SET | `isNull = false` (implicit in method signature) |
| 3 | CALL | `msg.set(key, value)` (inside `setRaw`) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `CAANMsg` | Class | Centralized Application ANd Message — the message envelope used for all inter-component communication (SC to CBS, screen to batch). Built on a schema-driven parameter system. |
| `CAANMsg.setNull(String key)` | Method | Marks a schema-defined field as null in the message envelope. Used when a parameter has no value. |
| `CAANMsg.set(String key, Object value)` | Method | Sets a schema-defined field to a specific value in the message envelope. |
| `setRaw` | Method | Internal utility that performs the actual null-aware set on `CAANMsg`. `set()` and `setDefaultIfNone()` are wrappers around it. |
| `MsgEditer` | Class | Message Editor — a utility class for building and manipulating CBS parameter messages. Embedded in `JKKWribSvcKeiOperateCC`. |
| `JKKWribSvcKeiOperateCC` | Class | Wire Service Contract Line Item Operation Control Component — a batch processing component that handles operations on wire (telecom) service contracts. |
| `JKKMineoSetPlanWribCC` | Class | Mineo Set Plan Wire Control Component — a batch component for setting service plans on the Mineo MVNO platform. |
| `KKW00101SFBean` | Class | Screen framework bean for service operation — a screen-level component that uses reflection to dynamically invoke methods. |
| `CBS` | Acronym | Call Back Service — the back-end processing component invoked by SCs. Also stands for "Contract Business System" in some contexts. |
| `SC` | Acronym | Screen Component — the front-end processing layer that handles screen logic and invokes CBS for business operations. |
| `KKW` | Prefix | Contract Wire (KK = 契約, W = Wire) — the module prefix for telecom wire service contract operations. |
| `KEY_WRIB_SVC_KEI_NO` | Field | Wire service contract line item number — the unique identifier for a specific line item within a wire service contract. |
| `KEY_SVC_KEI_NO` | Field | Service contract number — the primary key for a service contract. |
| `KEY_DCHSKMST_NO` | Field | Change service master number — identifier for the service master record being modified. |
| `KEY_WRIB_SVC_CD` | Field | Wire service code — a code identifying the type of wire service (e.g., FTTH, DSL). |
| `KEY_INTR_CD` | Field | Interest code — a code representing service interest/related codes. |
| `KEY_WORK_PARAM_ID` | Field | Work parameter identifier — a key for passing work-specific parameters in batch operations. |
| `KEY_RSV_APLY_YMD` | Field | Reservation application date — the date on which a service reservation application is made. |
| `EKK` | Prefix | Equipment Contract (KK = 契約) — CBS message class prefix for equipment contract operations. |
| `EZM` | Prefix | EZM — CBS message class prefix for Mineo mobile service operations. |
| `JPCModelConstant` | Class | JPC Model Constants — constant definitions for JPC (J:PPC) model-related constants including function codes. |
| `FUNC_CD_1` | Constant | Function code "1" — typically represents the primary/standard operation mode for a CBS invocation. |
| `FUNC_CD_2` | Constant | Function code "2" — typically represents a secondary/auxiliary operation mode for a CBS invocation. |
