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

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

## 1. Role

### SvcKeiFinderWithDchskmTrgtSvc.isCollect()

The `isCollect()` method is a private utility predicate helper that determines whether a service line item (`CAANMsg` representing a service type record) should be considered a "collect" match against a target service specification. It implements a **null-tolerant equality check**: when the target side (`valueFromWribSvcTrgtSvc`) is null or empty, the method returns `true`, meaning an unspecified field on the target side is treated as a wildcard that matches any value on the subject side. When the target side has an actual value, it performs a strict string equality comparison against the subject value (`valueFromSvcKei`).

This method serves as the **atomic comparison primitive** used by the `SvcKeiFinderWithDchskmTrgtSvc.evaluate()` predicate method. The enclosing `SvcKeiFinderWithDchskmTrgtSvc` class implements the `Predicater<CAANMsg>` functional interface and is used in a filter pattern (via the `select()` helper) to find service type records matching specific criteria. The `isCollect()` method is called four times per evaluation — once for each of the four dimension fields: `svcCd` (service code), `prcGrpCd` (process group code), `pcrsCd` (package code), and `pplanCd` (plan code). All four dimensions must pass their respective `isCollect()` checks for a match to be confirmed.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isCollect(valueFromWribSvcTrgtSvc, valueFromSvcKei)"])
    CHECK_NULL["valueFromWribSvcTrgtSvc is null or empty string"]

    START --> CHECK_NULL

    CHECK_NULL -- "true (null or empty target)" --> RETURN_TRUE["Return true
(empty target = wildcard match)"]

    CHECK_NULL -- "false (non-empty target)" --> COMPARE["String equals: valueFromWribSvcTrgtSvc.equals(valueFromSvcKei)"]

    COMPARE --> RETURN_RESULT["Return comparison result
(true if equal, false if not)"]

    RETURN_TRUE --> END_NODE(["Return / Next"])
    RETURN_RESULT --> END_NODE
```

The method follows a **defensive comparison** pattern common in telecom service matching logic. The "empty target matches all" semantics allow flexible querying: when a caller does not specify a constraint on a particular dimension (e.g., does not care about the service code), it passes an empty string, and the predicate accepts any value. Only when all four dimensions (`svcCd`, `prcGrpCd`, `pcrsCd`, `pplanCd`) are either matched or left as wildcards does the overall predicate return true.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `valueFromWribSvcTrgtSvc` | `String` | The **target-side value** from a discounted target service record (`wribSvcTrgtSvc`). This represents a field value extracted from the target service specification (service code, process group code, package code, or plan code). An empty or null value acts as a **wildcard**, meaning "no constraint on this dimension." |
| 2 | `valueFromSvcKei` | `String` | The **subject-side value** from a candidate service type record (`CAANMsg`). This is the actual value of the same field on the service line item being evaluated. It is compared against the target value to determine if the candidate matches the constraint. |

**Instance fields read by the method:** None directly — `isCollect()` is a pure utility method. However, it is always invoked through the `SvcKeiFinderWithDchskmTrgtSvc` instance, which holds the following instance fields (set in the constructor from a `CAANMsg` target service record):

| Field | Type | Business Description |
|-------|------|---------------------|
| `dchskmTrgtSvc` | `CAANMsg` | The discounted target service record. Contains `svcCd`, `prcGrpCd`, `pcrsCd`, `pplanCd` fields extracted during construction. |
| `svcCd` | `String` | Service code extracted from the target service record. Used as the target for the first `isCollect()` call. |
| `prcGrpCd` | `String` | Process group code extracted from the target service record. Used as the target for the second `isCollect()` call. |
| `pcrsCd` | `String` | Package code extracted from the target service record. Used as the target for the third `isCollect()` call. |
| `pplanCd` | `String` | Plan code extracted from the target service record. Used as the target for the fourth `isCollect()` call. |

## 4. CRUD Operations / Called Services

This method performs **no database operations or service component calls**. It is a pure, stateless string comparison utility with no side effects.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (none) | — | — | — | No CRUD operations — this is a pure utility predicate method. |

## 5. Dependency Trace

### Direct callers:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `SvcKeiFinderWithDchskmTrgtSvc.evaluate()` | `Predicater<CAANMsg>.evaluate(svcKei)` → `isCollect(targetValue, subjectValue)` | None — pure in-memory comparison |

The `SvcKeiFinderWithDchskmTrgtSvc` class is an anonymous/inner class implementing `Predicater<CAANMsg>` defined within `JKKWribSvcKeiOperateCC`. Its `evaluate()` method is invoked by the `select()` helper method (also defined in `JKKWribSvcKeiOperateCC`), which filters an `ArrayList<CAANMsg>` by applying the predicate to each element. This predicate-based selection pattern is used throughout the broader service type matching pipeline, where the system identifies which service line items should be included based on a target service specification.

**Callers of `isCollect` within the class** (called from `evaluate()` 4 times per invocation):

| Call Site | Line | Target Field |
|-----------|------|--------------|
| `isCollect(this.svcCd, svcKeiSvcCd)` | ~16866 | `svcCd` (service code) |
| `isCollect(this.prcGrpCd, svcKeiPrcGrpCd)` | ~16867 | `prcGrpCd` (process group code) |
| `isCollect(this.pcrsCd, svcKeiPcrsCd)` | ~16868 | `pcrsCd` (package code) |
| `isCollect(this.pplanCd, svcKeiPplanCd)` | ~16869 | `pplanCd` (plan code) |

The same `isCollect` method is also used by the sibling class `SvcKeiFinderWithTrgtSvc` (lines ~16805–16808), which has identical logic but references `wribSvcTrgtSvc` instead of `dchskmTrgtSvc`.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(null == valueFromWribSvcTrgtSvc || "".equals(valueFromWribSvcTrgtSvc))` (L~16892–16893)

> If the target-side value is null or an empty string, treat it as a wildcard — any subject value is considered a match. This implements the "no constraint" semantics for optional filter dimensions.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true;` | empty target = wildcard match |

**Block 1.1** — [ELSE-IMPLICIT] `(non-empty target)` (L~16895–16896)

> The target side has an actual value. Perform strict string equality comparison with the subject-side value. This ensures the candidate service line item matches the target specification exactly on this dimension.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `valueFromWribSvcTrgtSvc.equals(valueFromSvcKei)` | string equality comparison |
| 2 | RETURN | `return valueFromWribSvcTrgtSvc.equals(valueFromSvcKei);` | true if equal, false if not |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `isCollect` | Method | Wildcard-aware equality predicate — returns true if the target constraint is unspecified (empty/null) or if the target value matches the subject value exactly. Named "collect" as in "collect/match" rather than "gather". |
| `valueFromWribSvcTrgtSvc` | Parameter | Discounted target service field value — the constraint side of the comparison, extracted from the target service record (`wribSvcTrgtSvc`). An empty value means "no constraint on this dimension." |
| `valueFromSvcKei` | Parameter | Service type subject value — the actual value of the field on the candidate service line item being evaluated. |
| `Predicater<I>` | Interface | A functional interface (single method `evaluate(I)`) used to implement filter predicates. Enables the `select()`, `exist()`, `map()`, and `each()` generic collection operations defined in `JKKWribSvcKeiOperateCC`. |
| `CAANMsg` | Class | A message/data container class used throughout the system to represent structured business records. Fields are accessed via `getString(key)`. |
| `svcCd` | Field | Service code — identifies the type of telecom service (e.g., FTTH, DSL, TV, VoIP). One of four dimension fields used in service matching. |
| `prcGrpCd` | Field | Process group code — classifies the processing group/category for a service. One of four dimension fields. |
| `pcrsCd` | Field | Package code — identifies the service package bundle. One of four dimension fields. |
| `pplanCd` | Field | Plan code — identifies the specific service plan. One of four dimension fields. |
| `dchskmTrgtSvc` | Field | Discounted target service record (`CAANMsg`) — the target service specification that defines matching criteria for identifying related service lines. |
| `wribSvcTrgtSvc` | Field | Writing target service record (`CAANMsg`) — analogous to `dchskmTrgtSvc` but refers to a general write target rather than a discounted one. Used by the sibling `SvcKeiFinderWithTrgtSvc` class. |
| `select()` | Helper method | Generic collection filter — iterates an `ArrayList<I>` and returns a new list containing only elements for which the predicate's `evaluate()` returns true. |
| `wrib` | Term | Short for "writing" (registered/committed service records) — prefix used for service target records that have been written to the system. |
| `dchskm` | Term | Short for "discount" (割引) — prefix indicating this target service record involves a discount arrangement. |
| `svcKei` | Term | Short for "service type/genre" (サービス種目) — identifies individual service lines or service type records in the system. |
| `JKKWribSvcKeiOperateCC` | Class | Bulk processing common component for service type operations — contains utility methods and inner predicate classes for filtering and transforming service records. |
