# Business Logic — JKKStringUtil.isNullEmpty() [25 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.common.util.JKKStringUtil` |
| Layer | Utility |
| Module | `util` (Package: `eo.common.util`) |

## 1. Role

### JKKStringUtil.isNullEmpty()

The `isNullEmpty()` method is a shared utility method within the common component layer that provides null and empty-value validation for arbitrary Java objects. Its business purpose is to serve as a defensive guard that prevents downstream processing of null, blank-string, or empty-list data, which in a telecom services context typically represents missing or incomplete form input, optional query parameters, or defaulted collection fields. The method implements a polymorphic dispatch pattern: it inspects the runtime type of the input `Object` and applies the appropriate emptiness check — `null` check for generic references, `equals("")` for `String` instances, and `isEmpty()` for `ArrayList` instances. It acts as a reusable precondition checker called (or intended to be called) throughout the application wherever input validation is required before further business processing. By consolidating these checks into a single utility method, it eliminates repetitive conditional code across screens, CBS layers, and batch jobs, ensuring consistent handling of null and empty values. The method returns `false` for any non-null, non-empty value (including non-empty strings and non-empty lists), as well as for objects of unhandled types, thereby following a fail-open pattern for unknown types.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isNullEmpty(Object target)"])
    CHECK_NULL{"target == null ?"}
    RETURN_TRUE_1(["Return true"])
    CHECK_STRING{"target instanceof String ?"}
    CHECK_EMPTY_STR{"target.equals(\"\") ?"}
    RETURN_TRUE_2(["Return true"])
    CHECK_LIST{"target instanceof ArrayList ?"}
    CHECK_EMPTY_LIST{"((ArrayList) target).isEmpty() ?"}
    RETURN_TRUE_3(["Return true"])
    RETURN_FALSE(["Return false"])
    END_NODE(["Return / Next"])

    START --> CHECK_NULL
    CHECK_NULL -->|true| RETURN_TRUE_1
    RETURN_TRUE_1 --> END_NODE
    CHECK_NULL -->|false| CHECK_STRING
    CHECK_STRING -->|false| CHECK_LIST
    CHECK_STRING -->|true| CHECK_EMPTY_STR
    CHECK_EMPTY_STR -->|true| RETURN_TRUE_2
    RETURN_TRUE_2 --> END_NODE
    CHECK_EMPTY_STR -->|false| CHECK_LIST
    CHECK_LIST -->|false| RETURN_FALSE
    CHECK_LIST -->|true| CHECK_EMPTY_LIST
    CHECK_EMPTY_LIST -->|true| RETURN_TRUE_3
    RETURN_TRUE_3 --> END_NODE
    CHECK_EMPTY_LIST -->|false| RETURN_FALSE
    RETURN_FALSE --> END_NODE
```

**Processing Summary:**

1. **Null Check (L146-148):** The method first checks whether the input `target` is `null`. If it is, the method immediately returns `true`, indicating the value is considered "null or empty." This guards against `NullPointerException` for subsequent operations.

2. **String Empty Check (L150-155):** If the target is not null, the method checks whether it is an instance of `String`. If so, it calls `target.equals("")` to determine if the string is blank (zero-length). A blank string returns `true`. Note: whitespace-only strings are NOT considered empty by this method — they would pass through to the final `false` return.

3. **ArrayList Empty Check (L157-162):** If the target is not a String, the method checks whether it is an instance of `ArrayList`. If so, it casts the target to `ArrayList` and calls `isEmpty()` to check for an empty list. An empty list returns `true`.

4. **Fallback (L163):** For any value that does not match the above conditions — including non-empty strings, non-empty lists, objects of other types, or non-null non-empty values — the method returns `false`, indicating the value is considered "valid" (not null and not empty).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `target` | `Object` | An arbitrary Java object passed for null/empty validation. In business usage, this typically represents form input data, optional query parameters, or collection data that may legitimately be absent (null), blank (empty string), or contain no elements (empty list). The method handles String and ArrayList instances specifically; other types are treated as non-empty by default. |

**External State / Instance Fields:**
- None. This method is `static` and does not read any instance fields, thread-locals, or external state.

## 4. CRUD Operations / Called Services

This method performs no data access operations. It contains no calls to SC codes, CBS procedures, entity methods, or database operations. It is a pure in-memory validation utility.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No CRUD operations. Pure in-memory null/empty check. |

## 5. Dependency Trace

No external callers were found in the codebase for `isNullEmpty()`. The method is a utility designed to be invoked by other classes (screens, CBS layers, batch jobs) but currently has no callers in the search scope.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| — | — | — | — | No external callers found. Utility method awaiting callers. |

**Note:** As a static utility method in the common component layer (`eo.common.util`), `isNullEmpty()` is intended to be called from any layer — Controller/Screen classes, CBS (Component Business Service) classes, DAOs, or batch processes — wherever null/empty validation is needed before business logic proceeds.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(target == null)` (L146)

> Null guard: if the input object reference is null, return true immediately to signal the value is null or empty.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `if (target == null)` |
| 2 | RETURN | `return true;` |

**Block 2** — IF `(target instanceof String)` (L150)

> String emptiness check: if the target is a String, verify whether it is a blank (zero-length) string.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `if (target instanceof String)` |
| 2 | IF | `if (target.equals(""))` |
| 3 | RETURN | `return true;` |

**Block 2.1** — ELSE-IF branch for String with non-empty value

> When the String is not blank (i.e., has at least one character), execution falls through to the next type check.

| # | Type | Code |
|---|------|------|
| 1 | FALLTHROUGH | Control proceeds to Block 3 |

**Block 3** — IF `(target instanceof ArrayList)` (L157)

> ArrayList emptiness check: if the target is an ArrayList, cast it and check whether the list contains no elements.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `if (target instanceof ArrayList)` |
| 2 | CAST | `(ArrayList) target` |
| 3 | EXEC | `((ArrayList) target).isEmpty()` |
| 4 | IF | `if (isEmpty() == true)` |
| 5 | RETURN | `return true;` |

**Block 3.1** — ELSE branch for non-empty ArrayList or non-ArrayList types

> When the target is not an ArrayList, or is a non-empty ArrayList, fall through to the final return.

| # | Type | Code |
|---|------|------|
| 1 | FALLTHROUGH | Control proceeds to Block 4 |

**Block 4** — RETURN `(default)` (L163)

> Default fallback: any value that is not null, not a blank string, and not an empty list returns false (indicating the value is valid / not empty). This also covers objects of types not explicitly handled (e.g., Integer, Map, custom objects), which are treated as non-empty by default.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `isNullEmpty` | Method | Null-or-Empty check — validates that an object is either null, blank (for strings), or empty (for collections) |
| `target` | Parameter | The object under validation — represents business data that may be absent or empty |
| `String` | Java Type | Immutable character sequence — in business usage, represents text fields such as names, codes, or descriptions |
| `ArrayList` | Java Type | Dynamic array collection — in business usage, represents a list of data items (e.g., a list of selected services) |
| `eo.common.util` | Package | Enterprise Object common utilities — the shared component library providing cross-cutting helper methods |
| Utility Method | Design Pattern | A static, stateless helper method that performs a single, reusable operation without side effects |
| Guard Clause | Design Pattern | An early return that checks a precondition and exits immediately if the condition is not met |
| Polymorphic Dispatch | Design Pattern | Type-based branching where the method behavior depends on the runtime type of the input object |
