@Override
  public boolean equals(@Nullable Object obj) {
    if (!(obj instanceof S3ResourceId)) {
      return false;
    }
    S3ResourceId o = (S3ResourceId) obj;

    return scheme.equals(o.scheme) && bucket.equals(o.bucket) && key.equals(o.key);
  }
@Test
  public void testEquals() {
    S3ResourceId a = S3ResourceId.fromComponents("s3", "bucket", "a/b/c");
    S3ResourceId b = S3ResourceId.fromComponents("s3", "bucket", "a/b/c");
    assertEquals(a, b);
    assertEquals(b, a);

    b = S3ResourceId.fromComponents("s3", a.getBucket(), "a/b/c/");
    assertNotEquals(a, b);
    assertNotEquals(b, a);

    b = S3ResourceId.fromComponents("s3", a.getBucket(), "x/y/z");
    assertNotEquals(a, b);
    assertNotEquals(b, a);

    b = S3ResourceId.fromComponents("s3", "other-bucket", a.getKey());
    assertNotEquals(a, b);
    assertNotEquals(b, a);

    b = S3ResourceId.fromComponents("other", "bucket", "a/b/c");
    assertNotEquals(a, b);
    assertNotEquals(b, a);
  }