All Downloads are FREE. Search and download functionalities are using the official Maven repository.

technology.dice.dicewhere.downloader.destination.s3.ObjectPath Maven / Gradle / Ivy

There is a newer version: 1.3.12
Show newest version
package technology.dice.dicewhere.downloader.destination.s3;


import technology.dice.dicewhere.downloader.PathUtils;

public class ObjectPath {
  private final String bucket;
  private final String prefix;

  public static ObjectPath of(String prefix) {
    String sanitisedPrefix =
        PathUtils.removeLeadingCharacter(PathUtils.removeTrailingCharacter(prefix, "/"), "/");
    if (!sanitisedPrefix.contains("/")) {

      return new ObjectPath(sanitisedPrefix, "");
    }
    return new ObjectPath(
        prefix.substring(0, sanitisedPrefix.indexOf("/")),
        PathUtils.removeLeadingCharacter(
            sanitisedPrefix.substring(sanitisedPrefix.indexOf("/")), "/"));
  }

  private ObjectPath(String bucket, String prefix) {
    this.bucket = bucket;
    this.prefix = prefix;
  }

  public String getBucket() {
    return bucket;
  }

  public String getPrefix() {
    return prefix;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy