protected boolean matchesSafely()

in optional/src/main/java/com/spotify/hamcrest/optional/PresentOptional.java [37:51]


  protected boolean matchesSafely(
      final Optional<? extends T> item, final Description mismatchDescription) {
    if (item.isPresent()) {
      if (matcher.matches(item.get())) {
        return true;
      } else {
        mismatchDescription.appendText("was an Optional whose value ");
        matcher.describeMismatch(item.get(), mismatchDescription);
        return false;
      }
    } else {
      mismatchDescription.appendText("was not present");
      return false;
    }
  }