class Xs2aToSpiAddressMapper {

    public SpiAddress mapToSpiAddress(Xs2aAddress address) {
        if (address == null) {
            return null;
        }

        return new SpiAddress(
            address.getStreetName(),
            address.getBuildingNumber(),
            address.getTownName(),
            address.getPostCode(),
            Optional.ofNullable(address.getCountry()).map(Xs2aCountryCode::getCode).orElse(""));
    }

}