Make EppInput.getSingleExtension() return Optional, not @Nullable

This makes it harder to use it incorrectly by accident.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=181795813
This commit is contained in:
mcilwain 2018-01-12 14:45:46 -08:00 committed by Ben McIlwain
parent fbdb148540
commit 315e6d57bf
21 changed files with 290 additions and 239 deletions

View file

@ -155,13 +155,14 @@ public final class DomainDeleteFlow implements TransactionalFlow {
}
Duration redemptionGracePeriodLength = registry.getRedemptionGracePeriodLength();
Duration pendingDeleteLength = registry.getPendingDeleteLength();
DomainDeleteSuperuserExtension domainDeleteSuperuserExtension =
Optional<DomainDeleteSuperuserExtension> domainDeleteSuperuserExtension =
eppInput.getSingleExtension(DomainDeleteSuperuserExtension.class);
if (domainDeleteSuperuserExtension != null) {
if (domainDeleteSuperuserExtension.isPresent()) {
redemptionGracePeriodLength =
Duration.standardDays(domainDeleteSuperuserExtension.getRedemptionGracePeriodDays());
Duration.standardDays(
domainDeleteSuperuserExtension.get().getRedemptionGracePeriodDays());
pendingDeleteLength =
Duration.standardDays(domainDeleteSuperuserExtension.getPendingDeleteDays());
Duration.standardDays(domainDeleteSuperuserExtension.get().getPendingDeleteDays());
}
boolean inAddGracePeriod =
existingDomain.getGracePeriodStatuses().contains(GracePeriodStatus.ADD);