class ResourceLocator {

  @FromString
  public static ResourceLocator of(String locator) {
    ArgChecker.notNull(locator, "locator");
    try {
      if (locator.startsWith(CLASSPATH_URL_PREFIX)) {
        String urlStr = locator.substring(CLASSPATH_URL_PREFIX.length());
        return ofClasspath(urlStr);

      } else if (locator.startsWith(FILE_URL_PREFIX)) {
        String fileStr = locator.substring(FILE_URL_PREFIX.length());
        return ofFile(new File(fileStr));

      } else if (locator.startsWith(URL_PREFIX)) {
        String pathStr = locator.substring(URL_PREFIX.length());
        return ofUrl(new URL(pathStr));

      } else {
        return ofFile(new File(locator));
      }
    } catch (Exception ex) {
      throw new IllegalArgumentException("Invalid resource locator: " + locator, ex);
    }
  }

  private  ResourceLocator(String locator, BeanByteSource source);

}