public <T extends BuildableManifestTemplate> T getManifestTemplate(
      Class<T> manifestTemplateClass, BlobDescriptor containerConfigurationBlobDescriptor) {
    try {
      // Set up the JSON template.
      T template = manifestTemplateClass.getDeclaredConstructor().newInstance();

      // Adds the container configuration reference.
      DescriptorDigest containerConfigurationDigest =
          containerConfigurationBlobDescriptor.getDigest();
      long containerConfigurationSize = containerConfigurationBlobDescriptor.getSize();
      template.setContainerConfiguration(containerConfigurationSize, containerConfigurationDigest);

      // Adds the layers.
      for (Layer layer : image.getLayers()) {
        template.addLayer(
            layer.getBlobDescriptor().getSize(), layer.getBlobDescriptor().getDigest());
      }

      return template;

    } catch (InstantiationException
        | IllegalAccessException
        | NoSuchMethodException
        | InvocationTargetException ex) {
      throw new IllegalArgumentException(manifestTemplateClass + " cannot be instantiated", ex);
    }
  }
Gets the manifest as a JSON template. The {@code containerConfigurationBlobDescriptor} must be
the {@link BlobDescriptor} obtained by writing out the container configuration JSON returned
from {@link #getContainerConfiguration()}.

@param <T> child type of {@link BuildableManifestTemplate}.
@param manifestTemplateClass the JSON template to translate the image to.
@param containerConfigurationBlobDescriptor the container configuration descriptor.
@return the image contents serialized as JSON.
jib-core/src/main/java/com/google/cloud/tools/jib/image/json/ImageToJsonTranslator.java