class JsonToImageTranslator {

  public static Image toImage(V21ManifestTemplate manifestTemplate)
      throws LayerPropertyNotFoundException, BadContainerConfigurationFormatException {
    Image.Builder imageBuilder = Image.builder(V21ManifestTemplate.class);

    // V21 layers are in reverse order of V22. (The first layer is the latest one.)
    for (DescriptorDigest digest : Lists.reverse(manifestTemplate.getLayerDigests())) {
      imageBuilder.addLayer(new DigestOnlyLayer(digest));
    }

    if (manifestTemplate.getContainerConfiguration().isPresent()) {
      configureBuilderWithContainerConfiguration(
          imageBuilder, manifestTemplate.getContainerConfiguration().get());
    }
    return imageBuilder.build();
  }

  private  JsonToImageTranslator();

}