public NessieIcebergClient withReference(String requestedRef, String hash) {
    if (null == requestedRef
        || (getRef().getReference().getName().equals(requestedRef)
            && getRef().getHash().equals(hash))) {
      return this;
    }
    return new NessieIcebergClient(getApi(), requestedRef, hash, catalogOptions);
  }
@Test
  public void testWithReference() throws NessieNotFoundException {
    NessieIcebergClient client = new NessieIcebergClient(api, "main", null, ImmutableMap.of());

    assertThat(client.withReference(null, null)).isEqualTo(client);
    assertThat(client.withReference("main", null)).isNotEqualTo(client);
    assertThat(client.withReference("main", api.getReference().refName("main").get().getHash()))
        .isEqualTo(client);

    assertThat(client.withReference(BRANCH, null)).isNotEqualTo(client);
    assertThat(client.withReference(BRANCH, api.getReference().refName(BRANCH).get().getHash()))
        .isNotEqualTo(client);
  }