replaced instances of Optional::of with Optional::ofNullable (fixes #9183)

This commit is contained in:
Evan Kranzler 2022-06-29 18:32:15 -04:00
parent 015444d00f
commit deb29c0659
28 changed files with 36 additions and 71 deletions

View file

@ -9,7 +9,6 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.Objects;
import java.util.Optional;
/**
@ -41,8 +40,7 @@ public class BecomesBlockedAttachedTriggeredAbility extends TriggeredAbilityImpl
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = Optional
.of(getSourcePermanentOrLKI(game))
.filter(Objects::nonNull)
.ofNullable(getSourcePermanentOrLKI(game))
.map(Permanent::getAttachedTo)
.map(game::getPermanent)
.orElse(null);

View file

@ -63,7 +63,7 @@ class CastExiledFromHandCardEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Optional.of(getValue("exiledHandCardRef"))
Optional.ofNullable(getValue("exiledHandCardRef"))
.filter(Objects::nonNull)
.map(MageObjectReference.class::cast)
.map(mor -> mor.getCard(game))