Skip to content

Commit f46099d

Browse files
committed
chore: Enhance BcRegistryBusinessAdressesDto validation and address retrieval logic
1 parent a8bad1c commit f46099d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/ca/bc/gov/bc_registry_test/dto/bcregistry/BcRegistryBusinessAdressesDto.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ public record BcRegistryBusinessAdressesDto(
99
BcRegistryAddressDto mailingAddress,
1010
BcRegistryAddressDto deliveryAddress
1111
) {
12+
1213
public boolean isValid() {
13-
return mailingAddress != null || deliveryAddress != null;
14+
return (mailingAddress != null && mailingAddress.isValid())
15+
|| (deliveryAddress != null && deliveryAddress.isValid());
1416
}
1517

1618
public Set<BcRegistryAddressDto> addresses() {
1719
Set<BcRegistryAddressDto> addressDtoSet = new HashSet<>();
18-
if (mailingAddress != null)
20+
if (mailingAddress != null) {
1921
addressDtoSet.add(mailingAddress.withAddressType("mailing"));
20-
if (deliveryAddress != null)
22+
}
23+
if (deliveryAddress != null) {
2124
addressDtoSet.add(deliveryAddress.withAddressType("delivery"));
25+
}
2226
return addressDtoSet;
2327
}
2428
}

0 commit comments

Comments
 (0)