class 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);

}