Consider I have a simple models UserInfo and Passport:

```
public class UserInfo {
    private int age;
    private String passportId;
    // getters, setters
}

public class Passport {
    // empty
}

```

If user is older then 20 years I want to see his passport, in Java7 I do:

```
    UserInfo userInfo = new UserInfo();
    userInfo.setAge(22);
    userInfo.setPassportId(null);

    final Passport passport;
    if (userInfo.getAge() > 20) {
        if (userInfo.getPassportId() == null) {
            throw new IllegalArgumentException("Set passport");
        }
        else {
            passport = findPassportById(userInfo.getPassportId());
        }
    }

```

It is pretty straightforward but I want to use a Java8 **Optional< T >**.

Optional seems very handy if you need to do only one action with nullable:

1. throw an exception if null using **.orElseThrow()**
2. do some computation in case of value exists (in my case *findPassportById*) using **.ifPresent()**

But when I try to do both I am getting something ugly:

```
    String passportId = Optional.of(userInfo)
            .filter(x -> x.getAge() > 20)
            .map(UserInfo::getPassportId)
            .orElseThrow(() -> new IllegalArgumentException("Set passport"));

    final Passport passport;
    // null checks again? I don't want to!
    if (passportId != null) {
        passport = findPassportById(passportId);
    }

```

So there is any practice to refactor this common case in more clean way?

Thanks!