public void hasValue(@Nullable Object expected) {
    if (expected == null) {
      throw new NullPointerException("Optional cannot have a null value.");
    }
    if (actual == null) {
      failWithActual("expected an optional with value", expected);
    } else if (!actual.isPresent()) {
      failWithoutActual(fact("expected to have value", expected), simpleFact("but was absent"));
    } else {
      checkNoNeedToDisplayBothValues("get()").that(actual.get()).isEqualTo(expected);
    }
  }
@Test
  public void hasValue_failingWithWrongValue() {
    expectFailureWhenTestingThat(Optional.of("foo")).hasValue("boo");
    assertFailureValue("value of", "optional.get()");
  }