# Business Logic — JFUShokaishaCheckCC.nullToZero() [9 LOC]

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

## 1. Role

### JFUShokaishaCheckCC.nullToZero()

The `nullToZero` method is a defensive data-conversion utility that safely transforms a nullable String containing a numeric value into an `int`, substituting `0` when the input is `null` or empty. Its Javadoc states: "Converts an empty string to 0" (空文字の場合は0に変換する), and accepts a String argument representing a number (文字列（数字）) while returning an integer value (数値). As a private helper, it implements a guard-and-parse design pattern: it shields calling code from both `NullPointerException` (on null input) and `NumberFormatException` (by providing a safe default). Within the `JFUShokaishaCheckCC` validation component — which performs check operations related to service company additions/modifications (会社変更: kaisha henkou) — this method is used to safely handle date-field comparisons where a contract expiration date (期日: kibi) may be absent. It has no conditional branches by service type; it always applies the same null-to-zero substitution before delegating to `Integer.parseInt`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["nullToZero sParam"])
    STEP1["Assign wStr = sParam"]
    COND{IsNull check}
    ELSE_BRANCH["Set wStr to 0"]
    PARSE["Integer.parseInt wStr"]
    RETURN_NODE(["Return int value"])

    START --> STEP1 --> COND
    COND --> |true| ELSE_BRANCH --> PARSE
    COND --> |false| PARSE
    PARSE --> RETURN_NODE
```

**Step-by-step description:**

1. **Assign `wStr = sParam`** — The incoming parameter is copied to a local variable `wStr` so the original can remain unmodified. This is a defensive copy pattern.

2. **`JFUBPCommon.isNull(sParam)` — null/empty guard** — The method delegates to `JFUBPCommon.isNull()` to check whether the input string is `null` or an empty string. `JFUBPCommon.isNull(Object)` is a wrapper around `JFUCommonUtil.isNull(Object)` that provides the framework's standard null-check semantics.

3. **If null or empty — substitute `"0"`** — When the guard evaluates to `true`, `wStr` is overwritten with the literal string `"0"`, establishing the default value for a missing or blank numeric field.

4. **`Integer.parseInt(wStr)` — parse and coerce** — The resolved string (either the original value or the `"0"` default) is parsed into an `int`. If the string contains non-numeric characters, a `NumberFormatException` will propagate — the caller is expected to provide a valid numeric string in the non-null case.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `sParam` | `String` | A String representation of a numeric value, typically a date field (YYYYMMDD format) such as a contract expiration date (契約期日: keiyaku kibi). Can be `null` or empty when the date has not been set. |

**Instance fields / external state read:** None. This method is stateless and depends only on its parameter and the framework utility `JFUBPCommon`.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JFUBPCommon.isNull` | - | - | Framework null/empty check on the input String — no data access, just object identity and string emptiness validation |
| - | `Integer.parseInt` | - | - | JDK core library call — string-to-int coercion, no I/O or database interaction |

This method performs **no CRUD operations**. It is a pure function that transforms input data without any persistence, query, or external service interaction.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method in the same class.
Terminal operations from this method: `isNull` [-], `parseInt` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Same class: `chkIntrCd` | `chkIntrCd(ykKigenYmd)` -> `JFUShokaishaCheckCC.nullToZero(ykKigenYmd)` | `isNull` [N/A], `parseInt` [N/A] |

**Details:** The method is `private` and called exclusively from within `JFUShokaishaCheckCC.chkIntrCd()` at lines 242, 269, and 295. In those call sites, `nullToZero` is invoked with the `ykKigenYmd` (delivery deadline date) parameter to safely convert it to an integer for comparison against the current operation date (`opeDate`): `Integer.parseInt(opeDate) > nullToZero(ykKigenYmd)`. No external screens or batches call this method directly.

## 6. Per-Branch Detail Blocks

**Block 1** — [ASSIGNMENT] `wStr = sParam` (L403)

> Copy the input parameter to a local variable to preserve the original.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String wStr = sParam;` // Defensive copy of input parameter |

**Block 2** — [IF] `(JFUBPCommon.isNull(sParam))` (L404)

> Guard against null or empty input. The `JFUBPCommon.isNull` method delegates to `JFUCommonUtil.isNull`, which checks for both `null` reference and empty string `""`.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JFUBPCommon.isNull(sParam)` // Framework null/empty check |

**Block 2.1** — [IF-BRANCH] `(true)` (L405–L406)

> The input is null or empty. Substitute the default value `"0"` to ensure the subsequent parse never fails on a null reference.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wStr = "0";` // Default to zero when input is absent |

**Block 3** — [RETURN] (L408)

> Parse the resolved string as an integer. If `sParam` was non-null and non-empty, `wStr` holds the original value and will be parsed as-is. If `sParam` was null/empty, `wStr` is `"0"` and the result is `0`. A `NumberFormatException` propagates if the non-default string is not a valid integer.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Integer.parseInt(wStr);` // Coerce string to int, default 0 if empty |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sParam` | Parameter | Input string carrying a numeric value, typically a date in YYYYMMDD format |
| `ykKigenYmd` | Field | Delivery deadline date — the date by which a service delivery or installation is expected to be completed |
| `opeDate` | Field | Operation date — the current business date used for date comparisons |
| `JFUBPCommon.isNull` | Method | Framework utility that checks whether an object is null or a String is empty |
| `JFUShokaishaCheckCC` | Class | Company change check component — performs validation checks related to service company additions and modifications (会社変更) |
| `chkIntrCd` | Method | Interruption code check — validates service interruption-related fields during company change processing |
| CC | Abbreviation | Common Component — a shared validation/helper class in the Fujitsu Futurity BP framework |
