Class VersionFactoryCodeGenerator

java.lang.Object
com.google.ads.googleads.codegen.VersionFactoryCodeGenerator
All Implemented Interfaces:
Generator

public class VersionFactoryCodeGenerator extends Object implements Generator
Generates code for and writes the VersionCatalog class, which contains a method to retrieve a set of Version objects, one for each available version of the Google Ads library.

Example generated code snippets:

  
  public class VersionFactory {
    protected static ImmutableSet getVersions() throws IllegalAccessException,
      InstantiationException {
    ImmutableSet.Builder builder = ImmutableSet.builder();
      builder.add(new Version(
        "v1",
        com.google.ads.googleads.v1.errors.GoogleAdsException.Factory.class.newInstance(),
        com.google.ads.googleads.v1.services.GoogleAdsVersion.class));
       builder.add(new Version(
        "v2",
        com.google.ads.googleads.v2.errors.GoogleAdsException.Factory.class.newInstance(),
        com.google.ads.googleads.v2.services.GoogleAdsVersion.class));
      return builder.build();
    }
  }
  
  
  • Constructor Details

    • VersionFactoryCodeGenerator

      public VersionFactoryCodeGenerator(Set<Integer> versions, File targetDirectory)
      Creates an instance of the generator.
      Parameters:
      versions - available versions of the Google Ads library.
  • Method Details

    • generate

      public com.squareup.javapoet.JavaFile generate()
      Generates the code for the VersionCatalog class and writes the file.
      Specified by:
      generate in interface Generator
      Returns: