S3ResourceId implements ResourceId { @Nullable @Override public String getFilename() { if (!isDirectory()) { return key.substring(key.lastIndexOf('/') + 1); } if ("/".equals(key)) { return null; } String keyWithoutTrailingSlash = key.substring(0, key.length() - 1); return keyWithoutTrailingSlash.substring(keyWithoutTrailingSlash.lastIndexOf('/') + 1); } private  S3ResourceId(
      String bucket, String key, @Nullable Long size, @Nullable Date lastModified); @Override ResourceId resolve(String other, ResolveOptions resolveOptions); @Override ResourceId getCurrentDirectory(); @Override String getScheme(); @Nullable @Override String getFilename(); @Override boolean isDirectory(); @Override String toString(); @Override boolean equals(@Nullable Object obj); @Override int hashCode();  }
@Test public void testGetFilename() { assertNull(S3ResourceId.fromUri("s3: assertEquals("abc", S3ResourceId.fromUri("s3: assertEquals("abc", S3ResourceId.fromUri("s3: assertEquals("def", S3ResourceId.fromUri("s3: assertEquals("def", S3ResourceId.fromUri("s3: assertEquals("xyz.txt", S3ResourceId.fromUri("s3: }