public class CodeGenerator
extends java.lang.Object
| Constructor and Description |
|---|
CodeGenerator(java.lang.String projectId,
java.lang.String packageName,
java.io.File outputDir)
Constructs the CodeGenerator
|
| Modifier and Type | Method and Description |
|---|---|
com.squareup.javapoet.JavaFile |
generateSource(kontent.ai.delivery.ContentType type)
Returns a specification of the source representing this type in your Kontent.ai account.
|
java.util.List<com.squareup.javapoet.JavaFile> |
generateSources()
Returns a list of specifications of the sources representing the types in your Kontent.ai account
|
java.util.List<com.squareup.javapoet.JavaFile> |
generateSources(kontent.ai.delivery.DeliveryClient client)
Returns a list of specifications of the sources representing the types in your Kontent.ai account.
|
java.util.List<com.squareup.javapoet.JavaFile> |
generateSources(java.util.List<kontent.ai.delivery.ContentType> types)
Returns a list of specifications of the sources representing the types in your Kontent.ai account.
|
void |
writeSource(com.squareup.javapoet.JavaFile source)
Writes the provided specification to the outputDir provided in the constructor.
|
void |
writeSources(java.util.List<com.squareup.javapoet.JavaFile> sources)
Writes the provided specifications to the outputDir provided in the constructor.
|
public CodeGenerator(java.lang.String projectId,
java.lang.String packageName,
java.io.File outputDir)
projectId - the project id from your Kontent.ai accountpackageName - the package to place the generated models underoutputDir - the source root to place the generated modelsjava.lang.UnsupportedOperationException - when a there is a problem with the outputDirpublic java.util.List<com.squareup.javapoet.JavaFile> generateSources()
throws java.util.concurrent.ExecutionException,
java.lang.InterruptedException
java.util.concurrent.ExecutionException - when a problem occurs communicating with the Kontent.ai APIjava.lang.InterruptedException - when a problem occurs communicating with the Kontent.ai APIpublic java.util.List<com.squareup.javapoet.JavaFile> generateSources(kontent.ai.delivery.DeliveryClient client)
throws java.util.concurrent.ExecutionException,
java.lang.InterruptedException
DeliveryClient param is useful for testing, however in most environments, the default
generateSources() method should suffice.client - A DeliveryClient instance to use to generate the sources.java.util.concurrent.ExecutionException - when a problem occurs communicating with the Kontent.ai APIjava.lang.InterruptedException - when a problem occurs communicating with the Kontent.ai APIpublic java.util.List<com.squareup.javapoet.JavaFile> generateSources(java.util.List<kontent.ai.delivery.ContentType> types)
ContentType param is useful for testing, however in most environments, the default
generateSources() method should generally be the only method invoking this.types - A List of ContentType to generate the sources frompublic com.squareup.javapoet.JavaFile generateSource(kontent.ai.delivery.ContentType type)
generateSources() method should suffice.type - A ContentType to generate the source frompublic void writeSources(java.util.List<com.squareup.javapoet.JavaFile> sources)
throws java.io.IOException
generateSources(), but is separated in case you need to make modifications to your
specifications before writing.sources - A list of specificationsjava.io.IOException - when a problem occurs writing the source files, note some source may have been written when
this is thrownpublic void writeSource(com.squareup.javapoet.JavaFile source)
throws java.io.IOException
generateSources(), but is separated in case you need to make modifications to your
specification before writing.source - A specificationjava.io.IOException - when a problem occurs writing the source files