The javadoc for LicenseInfoFactory::getListedLicenseById states that it returns the "SPDX listed license or null if the ID is not in the SPDX license list". But, it looks like that for any value I pass in, it seems to return a SpdxListedLicense with the id set to that value (licenseId).
Therefore, instead of simply calling this method, I must check whether licenseId is contained in LicenseInfoFactory::getSpdxListedLicenseIds before calling the method.