
# Business Logic — JBSbatKKAdHenkoHoyuDataUpdOtr.getNullToStr() [8 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKAdHenkoHoyuDataUpdOtr` |
| Layer | Service (Batch Processing Service) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKAdHenkoHoyuDataUpdOtr.getNullToStr()

`getNullToStr` is a private utility method that performs null-safe string coercion within the address change data update batch process. Its sole business purpose is to prevent null pointer exceptions and blank-data contamination when reading address fields (postal codes, state/prefecture names, city/district names, block/street names, and house lot/number fields) from the service interface map during a location modification workflow. The method embodies a null-safety guard pattern — it is not an independent business operation but rather a defensive data transformer called inline wherever address data flows into the batch logic. It is invoked exclusively from `JBSbatKKAdHenkoHoyuDataUpdOtr.execute()`, the main processing method, across all address-related field extractions (both current and pre-change values) as well as address code lookups against the ZM_M_AD master table. By converting null or whitespace-only inputs to a safe empty string, it ensures downstream comparison logic (such as `adCd.equals(newAdCd)`) proceeds without throwing `NullPointerException`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getNullToStr(String str)"])
    COND1{str == null?}
    COND2{str.trim() equals \"\"?}
    RET_EMPTY(["Return \"\""])
    RET_STR(["Return str"])
    END(["Return value"])

    START --> COND1
    COND1 -- true --> RET_EMPTY
    COND1 -- false --> COND2
    COND2 -- true --> RET_EMPTY
    COND2 -- false --> RET_STR
```

**Processing Summary:**

1. **Null Check (L385)** — Evaluate whether the input string `str` is `null`. If `true`, return an empty string immediately (`""`).
2. **Blank/Whitespace Check (L385)** — If `str` is not null, invoke `String.trim()` to strip leading/trailing whitespace, then compare the result against the empty string literal `""`. If the trimmed string is empty (i.e., `str` contained only whitespace or was itself `""`), return an empty string (`""`).
3. **Passthrough (L388)** — If `str` is neither null nor blank/whitespace-only, return `str` as-is. This is the identity path — the input passes through unmodified.

The method implements a two-stage guard pattern: first guarding against `null`, then guarding against blank/whitespace-only content. Together, these ensure that any non-trivial string content (containing at least one non-whitespace character) is preserved, while null and blank values are normalized to `""`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `str` | `String` | An address field value extracted from the batch input map. It represents human-readable postal or geographic data such as postal code (`PCD`), prefecture name (`STATE_NM`), city name (`CITY_NM`), block/street name (`OAZTSU_NM`), house lot number (`AZCHO_NM`), and their pre-change counterparts (`OLD_*`). If the value is `null` (field not present) or blank/whitespace-only, the method returns `""` instead; otherwise it returns the original string unchanged. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatKKAdHenkoHoyuDataUpdOtr.getNullToStr` | - | - | Calls `trim()` on the input string for whitespace normalization |

**Note:** This method contains no CRUD operations, no database access, and no calls to external service components. The only method invoked internally is `String.trim()` on the input parameter, which is a standard Java library call (not a service component). The `"".equals(...)` comparison is a literal equality check against an empty string constant.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKAdHenkoHoyuDataUpdOtr | `JBSbatKKAdHenkoHoyuDataUpdOtr.execute(inMap)` -> `getNullToStr(str)` | `trim` [-], `equals` [-] |

**Caller Details:**

`getNullToStr` is called from within the `execute()` method of the same class (`JBSbatKKAdHenkoHoyuDataUpdOtr`). It is invoked on every address-related field read from the input `JBSbatServiceInterfaceMap`, including:

- **Current address fields:** postal code (`PCD`), prefecture name (`STATE_NM`), city name (`CITY_NM`), block/street name (`OAZTSU_NM`), house lot/number (`AZCHO_NM`)
- **Pre-change address fields:** old postal code (`OLD_PCD`), old prefecture name (`OLD_STATE_NM`), old city name (`OLD_CITY_NM`), old block/street name (`OLD_OAZTSU_NM`), old house lot/number (`OLD_AZCHO_NM`)
- **Address code fields:** current address code (`AD_CD`), new address code (`NEW_AD_CD`)
- **Master lookup fields:** when the current and new address codes match, the pre-change address values are read from the `ZM_M_AD` master table and also passed through `getNullToStr`

The method has no further downstream calls — it is a terminal leaf in the call graph.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(str == null || "".equals(str.trim()))` (L385)

> Guard branch: Returns empty string when the input is null or blank (whitespace-only). This prevents `NullPointerException` when `str` is null and handles the case where an address field exists in the map but contains only whitespace characters.

| # | Type | Code |
|---|------|------|
| 1 | COND | `str == null` // Null check — guards against null pointer on subsequent trim() call |
| 2 | COND | `"".equals(str.trim())` // Blank check — trims whitespace then compares to empty string literal [-> `""`] |
| 3 | RETURN | `return "";` // Returns empty string for null or blank input |

**Block 2** — [ELSE] (implicit, L388)

> Passthrough branch: Returns the original string unchanged when it contains at least one non-whitespace character. This preserves valid address data for downstream processing.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return str;` // Identity passthrough — returns the original non-null, non-blank string |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `PCD` | Field | Postal code — Japanese mailing address postal number |
| `STATE_NM` | Field | Prefecture name — Japanese administrative region (都道府県名) |
| `CITY_NM` | Field | City/town/village name — municipal area designation (市区町村名) |
| `OAZTSU_NM` | Field | Block/street name — large-area street designation (大字通称名) |
| `AZCHO_NM` | Field | House lot/number — specific property numbering (字丁目名) |
| `AD_CD` | Field | Current address code — internal identifier for the current registered address |
| `NEW_AD_CD` | Field | New address code — internal identifier for the changed/target address |
| `OLD_*` prefix | Field convention | Pre-change / before-change values — fields prefixed with `OLD_` hold the address values prior to the modification |
| `ZM_M_AD` | Table | Address master table — master reference table storing standardized address data |
| `CHG_AD_JGRTWK_NO` | Field | Address change work number — internal work tracking ID for the address modification job |
| `CHG_TG_SCHEMA_ID` | Field | Change target schema ID — identifies the schema/table category being modified |
| JBSbat | Acronym | K-Opticom Batch framework — enterprise batch processing framework used across the customer base system |
| `getNullToStr` | Method name convention | "Get null to string" — utility naming convention indicating null-to-empty-string conversion |

---
