Skip to content

Commit 3b1d5ca

Browse files
Rename SupplierService lookup key to productName for clarity
The service is looked up by product name throughout the codebase, not an actual product ID as the previous naming implied.
1 parent 2656d8e commit 3b1d5ca

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

backends-for-frontends/src/main/java/com/iluwatar/bff/service/SupplierService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public interface SupplierService {
3636
/**
3737
* Retrieves supplier stock records for a product.
3838
*
39-
* @param productId identifier of the product to check stock for
39+
* @param productName name of the product to check stock for
4040
* @return the list of supplier stock records for the product
4141
*/
42-
List<SupplierRecord> getSupplierRecords(String productId);
42+
List<SupplierRecord> getSupplierRecords(String productName);
4343
}

backends-for-frontends/src/main/java/com/iluwatar/bff/service/impl/InMemorySupplierService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@
3333
public final class InMemorySupplierService implements SupplierService {
3434

3535
/** Supplier records stored in memory, keyed by product name. */
36-
private final Map<String, List<SupplierRecord>> recordsByProductId;
36+
private final Map<String, List<SupplierRecord>> recordsByProductName;
3737

3838
/**
3939
* Creates the service with a fixed backing map of supplier records, keyed by product name.
4040
*
4141
* @param records the supplier data this service serves
4242
*/
4343
public InMemorySupplierService(final Map<String, List<SupplierRecord>> records) {
44-
this.recordsByProductId = records;
44+
this.recordsByProductName = records;
4545
}
4646

4747
@Override
48-
public List<SupplierRecord> getSupplierRecords(final String productId) {
49-
return recordsByProductId.getOrDefault(productId, List.of());
48+
public List<SupplierRecord> getSupplierRecords(final String productName) {
49+
return recordsByProductName.getOrDefault(productName, List.of());
5050
}
5151
}

0 commit comments

Comments
 (0)