---

# Business Logic — SvcKeiFinderWithTrgtSvc.isCollect() [10 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKWribSvcKeiOperateCC.SvcKeiFinderWithTrgtSvc.isCollect(String, String)` |
| Layer | Service / CC/Common Component (inner class within `JKKWribSvcKeiOperateCC`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### SvcKeiFinderWithTrgtSvc.isCollect()

The `isCollect` method is a private predicate helper that determines whether a single field value from a service code record (`valueFromSvcKei`) matches the corresponding field value extracted from a target service record (`valueFromWribSvcTrgtSvc`). It implements a **wildcard-match** pattern: when the target field is null or empty, the method returns `true`, treating the missing target as a wildcard that accepts any value. When the target field has a concrete value, it performs an exact string equality check.

This method is called multiple times within the `SvcKeiFinderWithTrgtSvc.evaluate()` method to compare four service contract fields — service code (`svc_cd`), processing group code (`prc_grp_cd`), product code (`pcrs_cd`), and plan code (`pplan_cd`) — between a discount service/target service configuration and a customer's actual service contract records. It serves as the atomic comparison primitive in a **predicate/filter design pattern**, enabling the parent class to match customer service contracts against eligibility criteria for discount services and data extraction items.

The method has no conditional branches beyond a single null/empty check followed by an equality comparison. It has no database interactions, no CRUD operations, and no external service calls. It is a pure, stateless utility method that performs one of the two possible outcomes: wildcard acceptance or exact value match.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isCollect(valueFromWribSvcTrgtSvc, valueFromSvcKei)"])

    START --> COND1{Is valueFromWribSvcTrgtSvc<br/>null or empty?}

    COND1 -->|Yes| RETURN_TRUE["Return true<br/>Treat missing target as wildcard"]
    COND1 -->|No| CMP["valueFromWribSvcTrgtSvc.equals(valueFromSvcKei)"]

    CMP --> RET_EQ["Return true<br/>Values match exactly"]
    CMP --> RET_NE["Return false<br/>Values differ"]

    RET_EQ --> END_N(["End"])
    RET_NE --> END_N
    RETURN_TRUE --> END_N
```

**Business Logic Description:**

1. **Step 1 — Null/Empty Check (wildcard detection):** The method first checks whether `valueFromWribSvcTrgtSvc` is `null` or an empty string (`""`). In the context of discount service eligibility determination, this field represents the expected service code, processing group code, product code, or plan code from the target/discount service definition. If the definition does not constrain this field (i.e., it is null or empty), the method returns `true`, meaning the target service definition accepts any value for this field — it is a wildcard/unconstrained match.

2. **Step 2 — Exact String Comparison:** If the target field has a non-empty value, the method performs an exact string equality comparison (`String.equals()`) between the target value and the service code's corresponding field value. If they match exactly, it returns `true`. Otherwise, it returns `false`, indicating this service code record does not satisfy the eligibility criteria for this particular field.

**CRITICAL — Design Pattern:**

This method is part of the **Predicate Pattern** (`Predicater<I>` interface). The parent class `SvcKeiFinderWithTrgtSvc` holds the "expected" values extracted from a target service record in its constructor, and its `evaluate()` method calls `isCollect()` for each of the four fields to determine whether a candidate service code record matches all constraints. The method is called by `Items.exist()` and `Items.select()` — utility methods that filter lists of `CAANMsg` objects using the predicate.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `valueFromWribSvcTrgtSvc` | `String` | The value of a specific field from a target/writing service record. This is the "expected" or "constraint" value. It comes from one of four fields (`svc_cd`, `prc_grp_cd`, `pcrs_cd`, `pplan_cd`) extracted from the `CAANMsg wribSvcTrgtSvc` object in the `SvcKeiFinderWithTrgtSvc` constructor. When `null` or `""`, it acts as a wildcard, meaning the target service definition does not impose a constraint on this field. |
| 2 | `valueFromSvcKei` | `String` | The value of the same field from a customer's service contract record (`CAANMsg svcKei`). This is the "actual" value being evaluated for eligibility. It contains the actual service code, processing group code, product code, or plan code associated with a customer's contract. |

**External State / Instance Fields Read:**
- None. This method is fully stateless and does not access any instance fields or external state. It depends only on its two parameters.

## 4. CRUD Operations / Called Services

This method performs **no CRUD operations**. It makes no database calls, no SC (Service Component) invocations, and no CBS (Business Service) calls. It contains only two operations:

| # | Type | Operation |
|---|------|-----------|
| 1 | CHECK | Null/empty check on `valueFromWribSvcTrgtSvc` |
| 2 | COMPARE | `String.equals()` exact string comparison |

## 5. Dependency Trace

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

The method is called exclusively through the `Predicater<CAANMsg>.evaluate()` method of the `SvcKeiFinderWithTrgtSvc` inner class. It is never called directly by any other method.

### Call Chain (from entry point to this method):

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0004 (via WribSvcKeiOperateCC) | `KKKWribSvcKeiOperateCC.isCollectTrgtSvcsAny()` → `SvcKeiFinderWithTrgtSvc.evaluate()` → `SvcKeiFinderWithTrgtSvc.isCollect()` | — (predicate match, no CRUD) |
| 2 | Screen:KKSV0004 (via WribSvcKeiOperateCC) | `KKKWribSvcKeiOperateCC.isCollectTrgtSvcsAll()` → `SvcKeiFinderWithTrgtSvc.evaluate()` → `SvcKeiFinderWithTrgtSvc.isCollect()` | — (predicate match, no CRUD) |
| 3 | Screen:KKSV0004 (via WribSvcKeiOperateCC) | `KKKWribSvcKeiOperateCC.resolveSvcKeiNos()` → `Items.select()` → `SvcKeiFinderWithTrgtSvc.evaluate()` → `SvcKeiFinderWithTrgtSvc.isCollect()` | — (predicate match, no CRUD) |

**Full Call Chain Details:**

1. **`isCollectTrgtSvcsAny(trgtSvcs, svcKeis)`** — Determines whether any discount service/target service has a matching customer contract. It iterates over target services, creates `SvcKeiFinderWithTrgtSvc` predicates, and uses `Items.exist()` which calls `evaluate()` → `isCollect()` for each field.

2. **`isCollectTrgtSvcsAll(trgtSvcs, svcKeis)`** — Determines whether ALL discount service/target services have matching customer contracts. Same flow but uses `!Items.exist()` to verify that NO non-matching records exist.

3. **`resolveSvcKeiNos(wribSvcTrgtSvc, svcKeis)`** — Extracts matching service code numbers. Creates a predicate, uses `Items.select()` to filter, then maps to `svc_kei_no` values.

**Downstream terminal operations from this method:** None. The `isCollect` method is a leaf-level comparison utility with no terminal SC or CRUD operations.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(null == valueFromWribSvcTrgtSvc || "".equals(valueFromWribSvcTrgtSvc))` (L16892)

> If the target/writing service field is null or empty, treat it as a wildcard — any value from the service code record is acceptable. This enables the predicate to express "unconstrained" fields in eligibility criteria.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `null == valueFromWribSvcTrgtSvc` |
| 2 | CHECK | `"".equals(valueFromWribSvcTrgtSvc)` |
| 3 | OR | Combine both checks with `\|\|` |
| 4 | RETURN | `return true;` |

**Block 2** — [ELSE] (implicit, when target is non-null and non-empty) (L16898)

> The target field has a concrete value. Perform exact string equality comparison between the target value and the service code's corresponding field value.

| # | Type | Code |
|---|------|------|
| 1 | COMPARE | `valueFromWribSvcTrgtSvc.equals(valueFromSvcKei)` |
| 2 | RETURN | `return valueFromWribSvcTrgtSvc.equals(valueFromSvcKei);` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `wribSvcTrgtSvc` | Field | Writing Service Target Service — the target/discount service record being evaluated for eligibility |
| `svcKei` | Field | Service Code — a customer's actual service contract record, containing the service code, processing group code, product code, and plan code |
| `svc_cd` | Field | Service Code — the primary service identifier (e.g., FTTH, TV, Phone) |
| `prc_grp_cd` | Field | Processing Group Code — groups services into processing categories |
| `pcrs_cd` | Field | Product Code — identifies the specific product offering |
| `pplan_cd` | Field | Plan Code — identifies the pricing/service plan |
| `svc_kei_no` | Field | Service Contract Number — the unique identifier for a service contract line item |
| CAANMsg | Class | A message/container object used throughout the codebase to carry structured key-value pairs representing database records or business entities |
| Predicater | Interface | A generic predicate interface (`Predicater<I>`) that defines a single `evaluate(I input)` method, used for filtering collections |
| Items.exist | Utility | A utility method that checks if any element in a list satisfies a given predicate |
| Items.select | Utility | A utility method that filters a list, returning elements that satisfy a given predicate |
| Discount Service | Business term | A service that provides price reductions or promotional pricing conditions tied to specific service contract combinations |
| Wildcard Match | Pattern | A matching strategy where null or empty values in the expected/constraint record are treated as accepting any value in the actual record |
| SYSID | Field | System ID — the customer identifier used to retrieve all associated service contracts |
| Eligibility Criteria | Business term | The set of conditions a customer's service contracts must satisfy for a discount service or data extraction item to be applicable |

---