public static ImageReference of(
      @Nullable String registry, String repository, @Nullable String tag, @Nullable String digest) {
    Preconditions.checkArgument(Strings.isNullOrEmpty(registry) || isValidRegistry(registry));
    Preconditions.checkArgument(isValidRepository(repository));
    Preconditions.checkArgument(Strings.isNullOrEmpty(tag) || isValidTag(tag));
    Preconditions.checkArgument(Strings.isNullOrEmpty(digest) || isValidDigest(digest));

    if (Strings.isNullOrEmpty(registry)) {
      registry = DOCKER_HUB_REGISTRY;
    }
    if (Strings.isNullOrEmpty(tag) && Strings.isNullOrEmpty(digest)) {
      tag = DEFAULT_TAG;
    }
    return new ImageReference(registry, repository, tag, digest);
  }
Constructs an {@link ImageReference} from the image reference components, consisting of an
optional registry, a repository, an optional tag, and an optional digest. If neither the tag
nor digest are specified, {@code tag} will take on the default value of {@code latest}.

@param registry the image registry, or {@code null} to use the default registry (Docker Hub)
@param repository the image repository
@param tag the image tag, or {@code null} to use the default tag ({@code latest})
@param digest the image digest
@return an {@link ImageReference} built from the given registry, repository, and tag
jib-core/src/main/java/com/google/cloud/tools/jib/api/ImageReference.java