# Business Logic — JBSbatKKBandWidthOverLmtDtTst.uniteAddress() [17 LOC]

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

## 1. Role

### JBSbatKKBandWidthOverLmtDtTst.uniteAddress()

This method aggregates a decomposed Japanese address into a single, concatenated address string. In the Japanese postal addressing system, addresses are stored in normalized, atomic components (prefecture, city, major district/commune, sub-district/chome, building name, room number, lot number). The `uniteAddress` method serves as a **address reassembler** that takes these seven independent address fields and stitches them together in a fixed canonical order, producing a human-readable, output-ready address string.

It implements the **filter-and-concatenate** design pattern: for each input field, it delegates to `checkBlank()` to silently drop `null` or empty values, then appends each non-blank component to a `StringBuilder`. This means the method is **null-safe** and **empty-string-tolerant** — it gracefully handles incomplete address data without throwing exceptions.

Within the larger system, this method is a **shared utility** called by the batch screen `KKSV0206` (Bandwidth Over-Limit Notification Message Output), specifically during the assembly of three distinct address types: the contractor's address (契約者住所), the billing recipient's address (請求書送付先住所), and the service location address (利用场所住所). It acts as a data-transformer that bridges the gap between normalized database storage and formatted output document generation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["uniteAddress(params)"])
    
    INIT["Initialize StringBuilder str"]
    
    A1["str.append(checkBlank(stateNm))"]
    A2["str.append(checkBlank(cityNm))"]
    A3["str.append(checkBlank(oaztsu))"]
    A4["str.append(checkBlank(azchoNm))"]
    A5["str.append(checkBlank(bnchigo))"]
    A6["str.append(checkBlank(adrTtm))"]
    A7["str.append(checkBlank(adrRm))"]
    
    FINAL["Return str.toString()"]
    
    START --> INIT
    INIT --> A1
    A1 --> A2
    A2 --> A3
    A3 --> A4
    A4 --> A5
    A5 --> A6
    A6 --> A7
    A7 --> FINAL
```

**Helper method — `checkBlank(String value)`**

```mermaid
flowchart TD
    A["checkBlank(value)"]
    B{"null != value"}
    C{"!empty string"}
    D["returnValue = value"]
    E["returnValue stays ''"]
    F["Return returnValue"]
    
    A --> B
    B -->|null| E
    B -->|not null| C
    C -->|empty| E
    C -->|not empty| D
    D --> F
    E --> F
```

**Explanation:**

The `uniteAddress` method follows a **straight-line sequential processing pattern** with no conditional branching of its own. The control flow is:

1. **Initialize** a `StringBuilder` to accumulate the concatenated result.
2. **Iterate through 7 address components** in fixed Japanese address order: Prefecture (都道府県) → City/Municipality (市町村) → Major District/Commune (大字通称名) → Sub-district/Chome (字丁目名) → Lot/Block Number (番地号) → Building/Supplementary Name (住所補記・建物名) → Room Number (住所補記・部屋番号).
3. For each component, invoke `checkBlank()` which returns the original value if non-null and non-empty, or an empty string otherwise.
4. Append each result to the `StringBuilder`.
5. **Return** the final concatenated string.

The `checkBlank` helper performs a null-and-empty guard: if the input is `null` or equals `""`, it returns `""` (empty string); otherwise, it returns the input value as-is. This ensures blank address components do not pollute the output.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `stateNm` | `String` | Prefecture name (都道府県名) — e.g., "Tokyo", "Osaka". The top-level geographic division in the Japanese address hierarchy. |
| 2 | `cityNm` | `String` | City/municipality name (市町村名) — e.g., "Shinjuku-ku", "Naka-ku". The second-level administrative division within a prefecture. |
| 3 | `oaztsu` | `String` | Major district/commune name (大字通称名) — a traditional large district name used in rural or semi-rural Japanese addresses, often preceding chome/block designations. |
| 4 | `azchoNm` | `String` | Sub-district/chome name (字丁目名) — the chome/block identifier within a city district (e.g., "3-chome"). The fourth level of the address hierarchy. |
| 5 | `bnchigo` | `String` | Lot/block number (番地号) — the street-level property identifier (e.g., "5-2"). Assigned to individual properties within a chome/district. |
| 6 | `adrTtm` | `String` | Building/supplementary name (住所補記・建物名) — optional building name or supplementary address information (e.g., "Sunrise Apartments", "Room 301 building info"). |
| 7 | `adrRm` | `String` | Room number (住所補記・部屋番号) — the specific unit or room number within a building, used for multi-unit properties. |

**Instance fields read:** None. This method is stateless and relies entirely on its parameters.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `checkBlank` | (private helper) | - | Calls `checkBlank(String)` to filter out null/empty values from each address component |

**Classification:** This method performs **no CRUD operations**. It is a pure data transformation — a string concatenation utility that reads input parameters and produces an output string. The only method it calls is `checkBlank()`, a private helper that performs null/empty checks on individual strings.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKBandWidthOverLmtDtTst | `execute()` → `uniteAddress()` (called 3 times for contractor, billing, and service location addresses) | `checkBlank` [-] |

**Details:** The `uniteAddress` method is invoked exactly 3 times within the `execute()` method of the same class (`JBSbatKKBandWidthOverLmtDtTst`), as part of a batch process that generates bandwidth over-limit notification messages. Each invocation constructs one of three address types:

- **Contractor address** (契約者住所): sourced from customer master (`JBSbatCK_T_CUST`) fields (`KEISHA_STATE_NM`, `KEISHA_CITY_NM`, `KEISHA_OAZTSU_NM`, `KEISHA_AZCHO_NM`, `KEISHA_BNCHIGO`, `KEISHA_ADRTTM`, `KEISHA_ADRRM`)
- **Billing recipient address** (請求書送付先住所): sourced from service contract billing info (`JBSbatKK_T_SEIKY_KEI`) fields (`SOHUS_STATE_NM`, `SOHUS_CITY_NM`, `SOHUS_OAZTSU_NM`, `SOHUS_AZCHO_NM`, `SOHUS_BNCHIGO`, `SOHUS_ADRTTM`, `SOHUS_ADRRM`)
- **Service location address** (利用场所住所): sourced from service detail work information (`JBSbatKK_T_SVKEI_KAISEN_UW`) fields (`KAISEN_PLACE_STATE_NM`, `KAISEN_PLACE_CITY_NM`, `KAISEN_PLACE_OAZTSU_NM`, `KAISEN_PLACE_AZCHO_NM`, `KAISEN_PLACE_BNCHIGO`, `KAISEN_PLACE_ADRTTM`, `KAISEN_PLACE_ADRRM`)

The resulting address strings are set into the output map (`kkifm206Map`) via `setString()` calls and ultimately written to notification documents.

## 6. Per-Branch Detail Blocks

> **Note:** This method contains no conditional branching (no if/else, switch/case, loops). The control flow is a single straight line of sequential `StringBuilder.append(checkBlank(...))` calls. Each block below represents one such call.

**Block 1** — [SET] `(Initialize StringBuilder)` (L888)

> Create a mutable string buffer to accumulate the concatenated address components.

| # | Type | Code |
|---|------|------|
| 1 | SET | `StringBuilder str = new StringBuilder()` |

**Block 2** — [CALL] `(Append prefecture name)` (L889)

> Check if `stateNm` (prefecture name) is non-null and non-empty; if so, append it to the address string.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(stateNm))` |

**Block 3** — [CALL] `(Append city/municipality name)` (L890)

> Check if `cityNm` (city/municipality name) is non-null and non-empty; if so, append it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(cityNm))` |

**Block 4** — [CALL] `(Append major district name)` (L891)

> Check if `oaztsu` (major district/commune name) is non-null and non-empty; if so, append it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(oaztsu))` |

**Block 5** — [CALL] `(Append sub-district/chome name)` (L892)

> Check if `azchoNm` (sub-district/chome name) is non-null and non-empty; if so, append it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(azchoNm))` |

**Block 6** — [CALL] `(Append lot/block number)` (L893)

> Check if `bnchigo` (lot/block number) is non-null and non-empty; if so, append it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(bnchigo))` |

**Block 7** — [CALL] `(Append building name)` (L894)

> Check if `adrTtm` (building/supplementary name) is non-null and non-empty; if so, append it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(adrTtm))` |

**Block 8** — [CALL] `(Append room number)` (L895)

> Check if `adrRm` (room number) is non-null and non-empty; if so, append it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `str.append(checkBlank(adrRm))` |

**Block 9** — [RETURN] `(Return concatenated address)` (L897)

> Return the fully assembled address string. If some components were null/empty, they are silently omitted from the output.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return str.toString()` |

### Helper Method: `checkBlank(String value)`

**Block H1** — [SET] `(Initialize return variable)` (L858)

> Initialize the return value to an empty string.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String returnValue = ""` |

**Block H2** — [IF] `(null != value && !"".equals(value))` (L860)

> Guard: only assign the input value if it is neither `null` nor an empty string. This prevents `NullPointerException` and avoids injecting blank values into the address string.

| # | Type | Code |
|---|------|------|
| 1 | SET | `returnValue = value` // assign input only if non-null and non-empty |

**Block H3** — [ELSE-IF/ELSE] `(value is null or empty)` (L860)

> If the value is `null` or equals `""`, the `returnValue` remains the initial empty string `""`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `returnValue` stays `""` | (implicit — no assignment executed) |

**Block H4** — [RETURN] `(Return check result)` (L865)

> Return either the original non-blank value or the empty string placeholder.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return returnValue` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `stateNm` | Field | Prefecture name (都道府県名) — the top-level administrative division in the Japanese address system (e.g., Tokyo, Osaka, Hokkaido) |
| `cityNm` | Field | City/municipality name (市町村名) — the second-level division within a prefecture (e.g., Shinjuku-ku, Naka-ku) |
| `oaztsu` | Field | Major district/commune name (大字通称名) — a traditional large district designation used in rural addresses, often the predecessor to chome/block numbering |
| `azchoNm` | Field | Sub-district/chome name (字丁目名) — the chome/block identifier within a district (e.g., "1-chome", "2-banchi") |
| `bnchigo` | Field | Lot/block number (番地号) — the specific property lot number within a chome (e.g., "5", "5-2") |
| `adrTtm` | Field | Building/supplementary name (住所補記・建物名) — optional building name or supplementary address info (e.g., apartment name, building identifier) |
| `adrRm` | Field | Room number (住所補記・部屋番号) — the specific unit or room number within a multi-unit building |
| `uniteAddress` | Method | Address reassembly utility — concatenates decomposed Japanese address components into a single output string |
| `checkBlank` | Method | Null/empty guard helper — returns the original value if non-null and non-empty, otherwise returns empty string |
| `KKSV0206` | Screen/Batch | Bandwidth over-limit notification message output batch screen — triggers address assembly for notification documents |
| 契約者住所 | Japanese term | Contractor address — the address of the service contract holder, sourced from customer master data |
| 請求書送付先住所 | Japanese term | Billing recipient address — the address where billing statements are sent, sourced from service contract billing info |
| 利用场所住所 | Japanese term | Service location address — the physical address where the service is deployed, sourced from service detail work data |
| `JBSbatCK_T_CUST` | Entity | Customer master table/entity — contains contractor information including full decomposed address fields |
| `JBSbatKK_T_SEIKY_KEI` | Entity | Service contract billing information table/entity — contains billing recipient details including decomposed address |
| `JBSbatKK_T_SVKEI_KAISEN_UW` | Entity | Service detail work (kaisen/extension) unit table/entity — contains the service location/deployment address details |
| `StringBuilder` | Java class | Mutable character sequence — used to efficiently concatenate the 7 address components into a single string |
