// then repeats this process for an artifact,
FilterControlledPermanent filter = new FilterControlledPermanent("artifact you control");
filter.add(new CardTypePredicate(CardType.ARTIFACT));
target = new TargetControlledPermanent(filter);
target.setNotTarget(true);
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
}
}