S3ResourceId implements ResourceId { @Override public ResourceId resolve(String other, ResolveOptions resolveOptions) { checkState(isDirectory(), "Expected this resource to be a directory, but was [%s]", toString()); if (resolveOptions == StandardResolveOptions.RESOLVE_DIRECTORY) { if ("..".equals(other)) { if ("/".equals(key)) { return this; } int parentStopsAt = key.substring(0, key.length() - 1).lastIndexOf('/'); return fromComponents(bucket, key.substring(0, parentStopsAt + 1)); } if ("".equals(other)) { return this; } if (!other.endsWith("/")) { other += "/"; } if (S3_URI.matcher(other).matches()) { return fromUri(other); } return fromComponents(bucket, key + other); } if (resolveOptions == StandardResolveOptions.RESOLVE_FILE) { checkArgument( !other.endsWith("/"), "Cannot resolve a file with a directory path: [%s]", other); checkArgument(!"..".equals(other), "Cannot resolve parent as file: [%s]", other); if (S3_URI.matcher(other).matches()) { return fromUri(other); } return fromComponents(bucket, key + other); } throw new UnsupportedOperationException( String.format("Unexpected StandardResolveOptions [%s]", resolveOptions)); } 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 testResolve() { for (TestCase testCase : PATH_TEST_CASES) { ResourceId resourceId = S3ResourceId.fromUri(testCase.baseUri); ResourceId resolved = resourceId.resolve(testCase.relativePath, testCase.resolveOptions); assertEquals(testCase.expectedResult, resolved.toString()); } assertEquals( S3ResourceId.fromUri("s3: S3ResourceId.fromUri("s3: assertEquals( S3ResourceId.fromUri("s3: S3ResourceId.fromUri("s3: .resolve("aa", RESOLVE_DIRECTORY) .resolve("bb", RESOLVE_DIRECTORY) .resolve("cc", RESOLVE_DIRECTORY)); assertEquals( S3ResourceId.fromUri("s3: S3ResourceId.fromUri("s3: assertEquals( S3ResourceId.fromUri("s3: S3ResourceId.fromUri("s3: assertEquals( S3ResourceId.fromUri("s3: S3ResourceId.fromUri("s3: }