# Business Logic — MsgEditer.setDefaultIfNone() [12 LOC]

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

## 1. Role

### MsgEditer.setDefaultIfNone()

`setDefaultIfNone` is a static utility method that provides a **conditional field-setting** pattern for `CAANMsg` objects — a message container used for data exchange between screens and service components in the Fujitsu Futurity business platform. Its purpose is to ensure that every message field has a meaningful value by applying a three-tier fallback strategy: first, the provided value; second, a user-specified default value; and third, `null` if neither is available.

The method implements a **guard-and-delegate** design pattern. It inspects the `value` parameter for null or empty string conditions, then delegates the actual message mutation to the lower-level `setRaw` method, which encapsulates the distinction between setting a typed field value (`msg.set(key, value)`) versus explicitly marking a field as null (`msg.setNull(key)`). This separation allows callers to express intent: when no value or default is available, the field is nulled rather than set to an empty string — a distinction that downstream validation logic depends on to differentiate between "no data provided" and "an empty value was explicitly set."

In the larger system, this method serves as a **shared data-initialization utility**. While no callers are currently traced in the codebase, it is defined within the `MsgEditer` inner class alongside other message-editing utilities (`set`, `setBulk`, `setRaw`), indicating it is part of a coordinated set of helpers used during message construction at screen entry points or service request assembly.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setDefaultIfNone(params)"])
    CHECK_VALUE(("value is null or empty?"))
    CHECK_DEFAULT(("defaultValue is null or empty?"))
    SET_NULL(["setRaw(msg, key, defaultValue, true)"])
    SET_DEFAULT(["setRaw(msg, key, defaultValue, false)"])
    SET_VALUE(["setRaw(msg, key, value, false)"])
    END_NODE(["Return / Next"])

    START --> CHECK_VALUE
    CHECK_VALUE -->|"Yes"| CHECK_DEFAULT
    CHECK_VALUE -->|"No"| SET_VALUE
    CHECK_DEFAULT -->|"Yes"| SET_NULL
    CHECK_DEFAULT -->|"No"| SET_DEFAULT
    SET_VALUE --> END_NODE
    SET_NULL --> END_NODE
    SET_DEFAULT --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msg` | `CAANMsg` | The message container being built or updated. `CAANMsg` is a schema-aware message object used throughout the Fujitsu platform to pass structured data between screens, service components, and data access layers. |
| 2 | `key` | `String` | The field identifier (schema key) within `msg` whose value is to be set. Corresponds to a field name defined in the `CAANMsg` schema, typically matching a database column or business data attribute (e.g., `svc_kei_no`, `cust_cd`). |
| 3 | `value` | `String` | The primary business value to assign to the field. If this is `null` or an empty string, the method falls through to the default-assignment logic. Represents the actual data the caller intends to populate. |
| 4 | `defaultValue` | `String` | The fallback value used when `value` is null or empty. If both `value` and `defaultValue` are null or empty, the field is explicitly nulled (not set to an empty string). Enables callers to specify a safe sentinel value. |

**External state:**
| Source | Description |
|--------|-------------|
| `MsgEditer.setRaw(msg, key, value, isNull)` | Static helper method that delegates to `CAANMsg.setNull(key)` when `isNull` is `true`, or `CAANMsg.set(key, value)` otherwise. Encapsulates the distinction between null and empty in the platform's message system. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `MsgEditer.setRaw` | - | `CAANMsg` field | Calls `setRaw` to update a field in `CAANMsg`. When `isNull` is true, calls `msg.setNull(key)` (sets the field to null). When `isNull` is false, calls `msg.set(key, value)` (sets the field to the provided value). |

**Classification notes:**
- This method does **not** perform any database or entity operations directly. It is purely an in-memory message mutation utility.
- The `setRaw` call is classified as **Update** because it modifies the state of the `CAANMsg` object's field, regardless of whether the mutation sets a value or nulls it.
- There is no SC code, CBS identifier, or database table involved — the data lives entirely within the application's message object.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | No callers found | Method is defined but has no invocations in the codebase | — |

**Notes:**
- A full-codebase search for references to `setDefaultIfNone(` returned zero call sites. This method is currently defined but unused — it may be dead code, or its callers may exist in a build artifact (e.g., compiled `.class` files from another project) not present in the source tree.
- No `Screen:KKSV*` entry points, batch jobs, or CBS classes reference this method.

## 6. Per-Branch Detail Blocks

> The method consists of two nested conditional blocks: an outer check on the primary `value`, and an inner check on `defaultValue` (executed only when `value` is null or empty).

**Block 1** — IF `(value is null or empty)` (L16565)

> If the primary value is missing, fall through to the default-assignment logic.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null == value || "".equals(value)` — Check if value is null or an empty string |

**Block 1.1** — IF-ELSE `(defaultValue is null or empty)` — nested under Block 1 (L16566)

> When the primary value is missing, check whether a usable default is available. If neither value nor default exists, set the field to `null`.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null == defaultValue || "".equals(defaultValue)` — Check if default is also missing |
| 2 | EXEC | `setRaw(msg, key, defaultValue, true)` — Branch: default is null/empty, so pass `isNull=true` to set the field to null |

**Block 1.1.1** — ELSE (defaultValue is NOT null or empty) (L16568)

> The primary value is missing but a valid default is provided. Use the default as the field's value.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `setRaw(msg, key, defaultValue, false)` — Branch: pass `isNull=false` so `msg.set(key, defaultValue)` is called, setting the field to the default value |

**Block 2** — ELSE `(value is NOT null or empty)` (L16571)

> The primary value is present and non-empty. Use it directly as the field's value, bypassing default logic entirely.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `setRaw(msg, key, value, false)` — Branch: pass `isNull=false` so `msg.set(key, value)` is called, setting the field to the provided value |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `CAANMsg` | Component | Fujitsu's schema-aware message object used for structured data exchange between screens, service components, and DAO layers. Provides type-safe field access via `set(key, value)`, `setNull(key)`, and `get(key)`. |
| `setRaw` | Method | Internal utility in `MsgEditer` that wraps `CAANMsg.set()` / `CAANMsg.setNull()` with a boolean switch, allowing callers to distinguish between setting a value and explicitly nulling a field. |
| `setNull` | Method | `CAANMsg` operation that explicitly sets a field to `null` in the message schema, as opposed to leaving it unset. Used to signal "no value intended" to downstream validation. |
| `set` | Method | `CAANMsg` operation that assigns a non-null value to a schema field. |
| Schema key | Domain concept | A string identifier that maps a message field to its type definition in the `CAANMsg` schema. Typically corresponds to a database column name or business data attribute. |
| Empty string guard | Pattern | The `"".equals(value)` check used to treat empty strings the same as `null` — both indicate "no meaningful data" for this utility method. |
