public class HollowAPIGenerator
extends java.lang.Object
HollowAPI
.
The generated java code is based on a data model (defined by a set of HollowSchema
), and will
contain convenience methods for traversing a dataset, based on the specific fields in the data model.
You may also run the main() method directly.Modifier and Type | Class and Description |
---|---|
static class |
HollowAPIGenerator.Builder |
static class |
HollowAPIGenerator.GeneratorArguments
An enumeration of possible arguments to the code generator when being called via the main
function.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
apiClassname |
protected CodeGeneratorConfig |
config |
protected HollowDataset |
dataset |
protected java.nio.file.Path |
destinationPath |
protected HollowErgonomicAPIShortcuts |
ergonomicShortcuts |
protected boolean |
hasCollectionsInDataSet |
protected java.lang.String |
packageName |
protected boolean |
parameterizeClassNames |
protected java.util.Set<java.lang.String> |
parameterizedTypes |
Modifier | Constructor and Description |
---|---|
|
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset)
Deprecated.
|
|
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
boolean parameterizeAllClassNames)
Deprecated.
|
|
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
boolean parameterizeAllClassNames,
java.nio.file.Path destinationPath) |
|
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
java.nio.file.Path destinationPath) |
|
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
java.util.Set<java.lang.String> parameterizeSpecificTypeNames)
Deprecated.
|
protected |
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
java.util.Set<java.lang.String> parameterizedTypes,
boolean parameterizeAllClassNames,
boolean useErgonomicShortcuts)
Deprecated.
construct with a
destinationPath and use generateSourceFiles() |
protected |
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
java.util.Set<java.lang.String> parameterizedTypes,
boolean parameterizeAllClassNames,
boolean useErgonomicShortcuts,
java.nio.file.Path destinationPath) |
|
HollowAPIGenerator(java.lang.String apiClassname,
java.lang.String packageName,
HollowDataset dataset,
java.util.Set<java.lang.String> parameterizedTypes,
java.nio.file.Path destinationPath) |
Modifier and Type | Method and Description |
---|---|
protected void |
generateFile(java.io.File directory,
HollowJavaFileGenerator generator)
Deprecated.
construct
HollowAPIGenerator with a destinationPath then call generateSourceFile(HollowJavaFileGenerator) |
void |
generateFiles(java.io.File directory)
Deprecated.
construct
HollowAPIGenerator with a destinationPath then call generateSourceFiles() |
void |
generateFiles(java.lang.String directory)
Deprecated.
construct
HollowAPIGenerator with a destinationPath then call generateSourceFiles() |
protected void |
generateFilesForHollowSchemas(java.io.File directory)
Deprecated.
construct
HollowAPIGenerator with a destinationPath then call generateSourceFilesForHollowSchemas() |
protected void |
generateSourceFile(HollowJavaFileGenerator generator) |
void |
generateSourceFiles()
Generate all files under
destinationPath |
protected void |
generateSourceFilesForHollowSchemas()
Generate files based on dataset schemas under
destinationPath |
protected HollowFactoryJavaGenerator |
getHollowFactoryGenerator(HollowSchema schema) |
protected HollowJavaFileGenerator |
getHollowObjectGenerator(HollowSchema schema) |
protected HollowJavaFileGenerator |
getStaticAPIGenerator(HollowSchema schema) |
protected static boolean |
hasCollectionsInDataSet(HollowDataset dataset)
Determines whether DataSet contains any collections schema
|
static void |
main(java.lang.String[] args)
Usage: java HollowAPIGenerator --argName1=argValue1 --argName2==argValue2.
|
void |
reservePrimaryKeyIndexForTypeWithPrimaryKey(boolean reservePrimaryKeyIndexForTypeWithPrimaryKey)
Use this method to specify to only generate PrimaryKeyIndex for Types that has PrimaryKey defined
Defaults to false to be backwards compatible
|
void |
setClassPostfix(java.lang.String classPostfix)
Use this method to override the default postfix "Hollow" for all generated Hollow object classes.
|
protected void |
setCodeGeneratorConfig(CodeGeneratorConfig config)
Set the CodeGeneratorConfig
|
void |
setGetterPrefix(java.lang.String getterPrefix)
Use this method to override the default prefix "_" for all getters on all generated Hollow object classes.
|
void |
setRestrictApiToFieldType(boolean restrictApiToFieldType)
If setRestrictApiToFieldType is true, api code only generates
get<FieldName> with return type as per schema
Defaults to false to be backwards compatible |
void |
setUseAggressiveSubstitutions(boolean useAggressiveSubstitutions)
Use this method to override generated classnames for type names corresponding to any class in the java.lang package.
|
void |
setUseBooleanFieldErgonomics(boolean useBooleanFieldErgonomics)
Use this method to specify to use new boolean field ergonomics for generated API
Defaults to false to be backwards compatible
|
void |
setUseHollowPrimitiveTypes(boolean useHollowPrimitiveTypes)
Use this method to specify to use Hollow Primitive Types instead of generating them per project
Defaults to false to be backwards compatible
|
void |
setUsePackageGrouping(boolean usePackageGrouping)
Use this method to specify to use sub packages in generated code instead of single package
Defaults to false to be backwards compatible
|
protected final java.lang.String apiClassname
protected final java.lang.String packageName
protected final java.nio.file.Path destinationPath
protected final HollowDataset dataset
protected final java.util.Set<java.lang.String> parameterizedTypes
protected final boolean parameterizeClassNames
protected final boolean hasCollectionsInDataSet
protected final HollowErgonomicAPIShortcuts ergonomicShortcuts
protected CodeGeneratorConfig config
public HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset)
HollowAPIGenerator(String, String, HollowDataset, Path)
and use generateSourceFiles()
apiClassname
- the class name of the generated implementation of HollowAPI
packageName
- the package name under which all generated classes will be placeddataset
- a HollowStateEngine containing the schemas which define the data model.public HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, java.nio.file.Path destinationPath)
apiClassname
- the class name of the generated implementation of HollowAPI
packageName
- the package name under which all generated classes will be placeddataset
- a HollowStateEngine containing the schemas which define the data model.destinationPath
- the directory under which the source files will be generatedpublic HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, boolean parameterizeAllClassNames)
HollowAPIGenerator(String, String, HollowDataset, boolean, Path)
and use generateSourceFiles()
apiClassname
- the class name of the generated implementation of HollowAPI
packageName
- the package name under which all generated classes will be placeddataset
- a HollowStateEngine containing the schemas which define the data model.parameterizeAllClassNames
- if true, all methods which return a Hollow Object will be parameterized. This is useful when
alternate implementations are desired for some types.public HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, boolean parameterizeAllClassNames, java.nio.file.Path destinationPath)
apiClassname
- the class name of the generated implementation of HollowAPI
packageName
- the package name under which all generated classes will be placeddataset
- a HollowStateEngine containing the schemas which define the data model.parameterizeAllClassNames
- if true, all methods which return a Hollow Object will be parameterized. This is useful when
alternate implementations are desired for some types.destinationPath
- the directory under which the source files will be generatedpublic HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, java.util.Set<java.lang.String> parameterizeSpecificTypeNames)
HollowAPIGenerator(String, String, HollowDataset, Set, Path)
and use generateSourceFiles()
apiClassname
- the class name of the generated implementation of HollowAPI
packageName
- the package name under which all generated classes will be placeddataset
- a HollowStateEngine containing the schemas which define the data model.parameterizeSpecificTypeNames
- methods with matching names which return a Hollow Object will be parameterized. This is useful when
alternate implementations are desired for some types.public HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, java.util.Set<java.lang.String> parameterizedTypes, java.nio.file.Path destinationPath)
apiClassname
- the class name of the generated implementation of HollowAPI
packageName
- the package name under which all generated classes will be placeddataset
- a HollowStateEngine containing the schemas which define the data model.parameterizedTypes
- the parameterized typesdestinationPath
- the directory under which the source files will be generatedprotected HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, java.util.Set<java.lang.String> parameterizedTypes, boolean parameterizeAllClassNames, boolean useErgonomicShortcuts)
destinationPath
and use generateSourceFiles()
apiClassname
- the api class namepackageName
- the api package namedataset
- the data setparameterizedTypes
- the set of parameterized typesparameterizeAllClassNames
- true if class names should be parameterizeduseErgonomicShortcuts
- true if ergonomic shortcuts should be usedprotected HollowAPIGenerator(java.lang.String apiClassname, java.lang.String packageName, HollowDataset dataset, java.util.Set<java.lang.String> parameterizedTypes, boolean parameterizeAllClassNames, boolean useErgonomicShortcuts, java.nio.file.Path destinationPath)
public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.ClassNotFoundException
HollowAPIGenerator.GeneratorArguments
for
available arguments.args
- the argumentsjava.io.IOException
- if a schema could not be read or the data model writtenjava.lang.ClassNotFoundException
- if a class of a data model cannot be loadedprotected static boolean hasCollectionsInDataSet(HollowDataset dataset)
dataset
- the data settrue
if the data set contains any collections schemaprotected void setCodeGeneratorConfig(CodeGeneratorConfig config)
config
- the configurationpublic void setClassPostfix(java.lang.String classPostfix)
classPostfix
- the postfix for all generated Hollow object classespublic void setGetterPrefix(java.lang.String getterPrefix)
getterPrefix
- the prefix for all generated getterspublic void setUseAggressiveSubstitutions(boolean useAggressiveSubstitutions)
useAggressiveSubstitutions
- true if applied.public void setUseBooleanFieldErgonomics(boolean useBooleanFieldErgonomics)
useBooleanFieldErgonomics
- true if applied.public void setUsePackageGrouping(boolean usePackageGrouping)
usePackageGrouping
- true if applied.public void reservePrimaryKeyIndexForTypeWithPrimaryKey(boolean reservePrimaryKeyIndexForTypeWithPrimaryKey)
reservePrimaryKeyIndexForTypeWithPrimaryKey
- true if applied.public void setUseHollowPrimitiveTypes(boolean useHollowPrimitiveTypes)
useHollowPrimitiveTypes
- true if applied.public void setRestrictApiToFieldType(boolean restrictApiToFieldType)
get<FieldName>
with return type as per schema
Defaults to false to be backwards compatiblerestrictApiToFieldType
- true if applied.public void generateSourceFiles() throws java.io.IOException
destinationPath
java.io.IOException
- if the files cannot be generatedpublic void generateFiles(java.lang.String directory) throws java.io.IOException
HollowAPIGenerator
with a destinationPath
then call generateSourceFiles()
directory
- the directory under which to generate filesjava.io.IOException
- if the files cannot be generatedpublic void generateFiles(java.io.File directory) throws java.io.IOException
HollowAPIGenerator
with a destinationPath
then call generateSourceFiles()
directory
- the directory under which to generate filesjava.io.IOException
- if the files cannot be generatedprotected void generateSourceFilesForHollowSchemas() throws java.io.IOException
destinationPath
java.io.IOException
- if the files cannot be generatedprotected void generateFilesForHollowSchemas(java.io.File directory) throws java.io.IOException
HollowAPIGenerator
with a destinationPath
then call generateSourceFilesForHollowSchemas()
directory
- the directory under which to generate filesjava.io.IOException
- if the files cannot be generatedprotected void generateSourceFile(HollowJavaFileGenerator generator) throws java.io.IOException
java.io.IOException
protected void generateFile(java.io.File directory, HollowJavaFileGenerator generator) throws java.io.IOException
HollowAPIGenerator
with a destinationPath
then call generateSourceFile(HollowJavaFileGenerator)
directory
- the directory under which to generate a filegenerator
- the file generatorjava.io.IOException
- if the file cannot be generatedprotected HollowJavaFileGenerator getStaticAPIGenerator(HollowSchema schema)
protected HollowJavaFileGenerator getHollowObjectGenerator(HollowSchema schema)
protected HollowFactoryJavaGenerator getHollowFactoryGenerator(HollowSchema schema)