@Beta public class DataModelGenerator extends Object
ODataToVdmGenerator
, gathering all relevant parameter or providing default values for
unspecified ones.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ANNOTATION_STRATEGY
The default fully-qualified name of the class to use for providing generated Java classes with necessary
annotations.
|
static String |
DEFAULT_BASE_PATH
The default base path, used in absence of a swagger file to determine a service path.
|
static String |
DEFAULT_COPYRIGHT_HEADER
The default copyright header that is added to generated files.
|
static Boolean |
DEFAULT_DELETE_OUTPUT_DIRECTORY
The default flag indicating whether the output directory should be deleted prior to the generation.
|
static String |
DEFAULT_EXCLUDES_PATTERN
The default ant style pattern of filenames for which VDM should not be generated - empty string.
|
static Boolean |
DEFAULT_FAIL_ON_WARNING
The default flag indicating whether to exit with a failure in case a warning occurs.
|
static String |
DEFAULT_INPUT_DIRECTORY_NAME
The default directory name to search and save configuration data in.
|
static Boolean |
DEFAULT_LINK_TO_API_BUSINESS_HUB
The default flag indicating whether to generate API reference URLs linking to the SAP API Business Hub.
|
static DefaultNamingStrategy.NameSource |
DEFAULT_NAMING_SOURCE
The default naming source used in the
DefaultNamingStrategy . |
static String |
DEFAULT_NAMING_STRATEGY
The default fully-qualified name of the class to use for converting names from the OData world to the Java world.
|
static String |
DEFAULT_OUTPUT_DIRECTORY_NAME
The default directory name to store the generated sources in.
|
static Boolean |
DEFAULT_OVERWRITE_FILES
The default flag indicating whether already existing files should be overwritten.
|
static String |
DEFAULT_PACKAGE_NAME
The default package prefix of the generated sources.
|
static Boolean |
DEFAULT_POJOS_ONLY
The default flag indicating whether to generate just the POJO classes (entities and complex types).
|
static String |
DEFAULT_SERVICE_NAME_MAPPING_FILE_NAME
The default file name to the name mapping properties file.
|
static Boolean |
DEFAULT_VERSION_REFERENCE
The default flag indicating whether to skip generating comments indicating the version reference of the used
OData generator plugin.
|
static String |
SAP_COPYRIGHT_HEADER
An SAP copyright header that can be added to generated files.
|
Constructor and Description |
---|
DataModelGenerator() |
Modifier and Type | Method and Description |
---|---|
DataModelGenerator |
copyrightHeader(String copyrightHeader)
Defines a copyright header to be placed at the beginning of generated files.
|
DataModelGenerator |
deleteOutputDirectory()
Deletes the output directory specified by
withPackageName(String) prior to generating the sources. |
DataModelGenerator |
deleteOutputDirectory(boolean deleteOutputDirectory)
Defines whether to delete the output directory specified by
withPackageName(String) prior to generating
the sources. |
void |
execute()
Executes the actual generator based on the given parameter or, in case of absence, their default values.
|
DataModelGenerator |
failOnWarning()
The generator exists with failure in case a warning occurs during processing.
|
DataModelGenerator |
failOnWarning(boolean failOnWarning)
Defines whether to exit with failure in case a warning occurs during processing.
|
boolean |
failureDueToWarningsNecessary()
Get the failure indicator due to warning messages.
|
protected AnnotationStrategy |
getAnnotationStrategy()
Getter for the class which provides generated Java classes with necessary annotations.
|
protected String |
getCopyrightHeader()
Getter for the copyright header to be added to generated files.
|
protected String |
getDefaultBasePath()
Getter for the default base path.
|
protected String |
getExcludeFilePattern()
The ant style filename pattern for which VDM should not be generated.
|
protected Set<String> |
getIncludedActionImports()
Getter for the list of action imports to process.
|
protected Set<String> |
getIncludedEntitySets()
Getter for the list of entity sets to process.
|
protected Set<String> |
getIncludedFunctionImports()
Getter for the list of function imports to process.
|
protected File |
getInputDirectory()
Getter for the directory containing the metadata and swagger files.
|
protected DefaultNamingStrategy.NameSource |
getNameSource()
Getter for the given
DefaultNamingStrategy.NameSource . |
protected NamingStrategy |
getNamingStrategy()
Getter for the class which converts OData names to Java names.
|
protected File |
getOutputDirectory()
Getter for the directory the generated files should be written into.
|
protected String |
getPackageName()
Getter for the prefix of the java package the generated files should be located in.
|
protected File |
getServiceNameMappings()
Getter for the file containing the custom service names.
|
protected boolean |
isDeleteTargetDirectory()
Getter for the flag indicating that the
#getOutputDirectory() should be cleared before generating new
files. |
protected boolean |
isFailOnWarning()
Getter for the flag indicating whether the generator fails in case a warning occurs.
|
protected boolean |
isForceFileOverride()
Getter for the flag indicating that already existing files in the
#getOutputDirectory() can be
overridden. |
protected boolean |
isGenerateLinksToApiBusinessHub()
Getter for the flag indicating whether to generate API reference URLs linking to the SAP API Business Hub.
|
protected boolean |
isGeneratePojosOnly()
Getter for the flag indicating whether to generate just the POJO classes.
|
protected boolean |
isGenerateVersionReference()
Getter for the flag indicating whether to generate comments referencing the used OData code generator version.
|
DataModelGenerator |
linkToApiBusinessHub()
Activates generation of API reference URLs linking to the SAP API Business Hub.
|
DataModelGenerator |
linkToApiBusinessHub(boolean linkToApiBusinessHub)
Defines whether to generate API reference URLs linking to the SAP API Business Hub.
|
DataModelGenerator |
overwriteFiles()
Defines that already existing files will get overwritten.
|
DataModelGenerator |
overwriteFiles(boolean overwriteFiles)
Defines whether already existing files will get overwritten.
|
DataModelGenerator |
pojosOnly()
Activates POJO only generation, so just entity and complex type classes are generated.
|
DataModelGenerator |
pojosOnly(boolean pojosOnly)
Defines whether to generate just the POJO classes (entities and complex types).
|
protected void |
printExecuteInformation()
Prints all information gathered in this builder.
|
DataModelGenerator |
sapCopyrightHeader()
Generate SAP copyright headers at the top of generated files.
|
DataModelGenerator |
versionReference()
Generate comments, which indicate the version of the used OData VDM generator plugin.
|
DataModelGenerator |
versionReference(boolean versionReference)
Defines whether to generate the version reference of the used OData generator plugin.
|
DataModelGenerator |
withAnnotationStrategy(AnnotationStrategy annotationStrategy)
Sets the class to use to provide generated Java classes with necessary annotations.
|
DataModelGenerator |
withAnnotationStrategy(String annotationStrategyClassName)
Sets the class to use to provide generated Java classes with necessary annotations.
|
DataModelGenerator |
withDefaultBasePath(String defaultBasePath)
Specifies the default base path.
|
DataModelGenerator |
withExcludeFilePattern(String excludeFilePattern)
The ant style filename pattern for which VDM should not be generated.
|
DataModelGenerator |
withIncludedActionImports(Set<String> includedActionImports)
Restricts the generated action imports to the provided values, plus any dependent complex types.
|
DataModelGenerator |
withIncludedEntitySets(Set<String> includedEntitySets)
Restricts the generated entity classes to the provided values, plus any dependent complex types.
|
DataModelGenerator |
withIncludedFunctionImports(Set<String> includedFunctionImports)
Restricts the generated function imports to the provided values, plus any dependent complex types.
|
DataModelGenerator |
withInputDirectory(File inputDirectory)
Input directory that contains the service definition files.
|
DataModelGenerator |
withInputDirectory(String inputDirectory)
Path to the input directory that contains the service definition files.
|
DataModelGenerator |
withNameSource(DefaultNamingStrategy.NameSource nameSource)
Getter for the given
DefaultNamingStrategy.NameSource . |
DataModelGenerator |
withNamingStrategy(NamingStrategy namingStrategy)
Sets the class to use to convert OData names into suitable Java names.
|
DataModelGenerator |
withNamingStrategy(String namingStrategyClassName)
Sets the class to use to convert OData names into suitable Java names.
|
DataModelGenerator |
withOutputDirectory(File outputDirectory)
Output directory to store the generated sources in.
|
DataModelGenerator |
withOutputDirectory(String outputDirectory)
Path to the output directory to store the generated sources in.
|
DataModelGenerator |
withPackageName(String packageName)
Specifies the package prefix to be used in the generated sources.
|
DataModelGenerator |
withServiceNameMapping(File serviceNameMappingFile)
The properties file containing the service name mapping.
|
DataModelGenerator |
withServiceNameMapping(String serviceNameMappingFile)
The path to the properties file containing the service name mapping.
|
public static final String DEFAULT_INPUT_DIRECTORY_NAME
public static final String DEFAULT_OUTPUT_DIRECTORY_NAME
public static final Boolean DEFAULT_DELETE_OUTPUT_DIRECTORY
public static final Boolean DEFAULT_OVERWRITE_FILES
false
, an exception
is thrown if a file already exists.public static final String DEFAULT_PACKAGE_NAME
public static final String DEFAULT_BASE_PATH
public static final String DEFAULT_SERVICE_NAME_MAPPING_FILE_NAME
public static final String DEFAULT_NAMING_STRATEGY
public static final String DEFAULT_ANNOTATION_STRATEGY
public static final DefaultNamingStrategy.NameSource DEFAULT_NAMING_SOURCE
DefaultNamingStrategy
.public static final Boolean DEFAULT_POJOS_ONLY
public static final String DEFAULT_EXCLUDES_PATTERN
public static final Boolean DEFAULT_LINK_TO_API_BUSINESS_HUB
public static final Boolean DEFAULT_FAIL_ON_WARNING
public static final Boolean DEFAULT_VERSION_REFERENCE
public static final String DEFAULT_COPYRIGHT_HEADER
public static final String SAP_COPYRIGHT_HEADER
@Nonnull public DataModelGenerator withInputDirectory(@Nonnull String inputDirectory)
inputDirectory
- The directory to read the service data from.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withInputDirectory(@Nonnull File inputDirectory)
inputDirectory
- The directory to read the service data from.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withOutputDirectory(@Nonnull String outputDirectory)
The generated sources will be stored under this directory according to the packages specified.
outputDirectory
- The path to the root directory to store the generated sources in.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withOutputDirectory(@Nonnull File outputDirectory)
The generated sources will be stored under this directory according to the packages specified.
outputDirectory
- The root directory to store the generated sources in.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator deleteOutputDirectory()
withPackageName(String)
prior to generating the sources.
This option should be used to determine the whole change set, including deleted files.
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator deleteOutputDirectory(boolean deleteOutputDirectory)
withPackageName(String)
prior to generating
the sources.
This option should be used to determine the whole change set, including deleted files.
deleteOutputDirectory
- Flag indicating whether the output directory should be cleaned.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator overwriteFiles()
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator overwriteFiles(boolean overwriteFiles)
false
, an exception is thrown if a file
already exists.overwriteFiles
- Flag indicating whether already existing files can be overwritten.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withPackageName(@Nonnull String packageName)
packageName
- The package prefix for the generated sources.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withDefaultBasePath(@Nullable String defaultBasePath)
If no swagger file is given, this base path, together with the metadata file name, constitute the service path with the following pattern: <defaultBasePath> + <metadataFileNameWithoutExtension>.
defaultBasePath
- The default base path.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withServiceNameMapping(@Nonnull File serviceNameMappingFile)
Any service not mapped in this file will get created/updated.
serviceNameMappingFile
- The file to read/set the service name mappings in.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withServiceNameMapping(@Nonnull String serviceNameMappingFile)
Any service not mapped in this file will get created/updated.
serviceNameMappingFile
- The file to read/set the service name mappings in.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withNamingStrategy(@Nonnull NamingStrategy namingStrategy)
namingStrategy
- Instance of a class, which must either implement the CodeNamingStrategy
interface, or extend a class which implements this interface.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withNamingStrategy(@Nonnull String namingStrategyClassName)
namingStrategyClassName
- Fully-qualified name of a class, which must either implement the NamingStrategy
interface, or extend a class which implements this interface.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withNameSource(@Nonnull DefaultNamingStrategy.NameSource nameSource)
DefaultNamingStrategy.NameSource
.
If the namingStrategy
is DefaultNamingStrategy
, this enum will be used to determine the actual
source of the java name.
nameSource
- The NameSource
to be used by the DefaulNamingStrategy
.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withAnnotationStrategy(@Nonnull AnnotationStrategy annotationStrategy)
annotationStrategy
- Instance of a class, which must either implement the AnnotationStrategy
interface, or extend a class which implements this interface.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withAnnotationStrategy(@Nonnull String annotationStrategyClassName)
annotationStrategyClassName
- Fully-qualified name of a class, which must either implement the AnnotationStrategy
interface, or extend a class which implements this interface.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator failOnWarning(boolean failOnWarning)
failOnWarning
- Flag indicating whether to generate just the POJO classes.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator failOnWarning()
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator pojosOnly(boolean pojosOnly)
pojosOnly
- Flag indicating whether to generate just the POJO classes.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator pojosOnly()
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withExcludeFilePattern(@Nonnull String excludeFilePattern)
excludeFilePattern
- Provide the ant style pattern for filenames for which VDM should not be generated.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator linkToApiBusinessHub(boolean linkToApiBusinessHub)
linkToApiBusinessHub
- Flag indicating whether to generate URLs.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator linkToApiBusinessHub()
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator versionReference(boolean versionReference)
versionReference
- Flag indicating whether to generate the comments.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator versionReference()
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator copyrightHeader(String copyrightHeader)
#defaultSAPCopyrightHeaders
.copyrightHeader
- The copyright header to add to generated files.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator sapCopyrightHeader()
DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withIncludedEntitySets(@Nullable Set<String> includedEntitySets)
includedEntitySets
- List of entity set names to generate classes for. These names must exist in the provided EDMX files in
order to be recognized. If a null value is provided, then all entity sets will be generated.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withIncludedFunctionImports(@Nullable Set<String> includedFunctionImports)
withIncludedEntitySets(Set)
(or
generate all entity sets). Otherwise the function import code cannot be generated.includedFunctionImports
- List of function import names to generate code for. These names must exist in the provided EDMX files
in order to be recognized. If a null value is provided, then all function imports will be generated.DataModelGenerator
for chained method calls.@Nonnull public DataModelGenerator withIncludedActionImports(@Nullable Set<String> includedActionImports)
withIncludedEntitySets(Set)
(or
generate all entity sets). Otherwise the action import code cannot be generated.includedActionImports
- List of action import names to generate code for. These names must exist in the provided EDMX files in
order to be recognized. If a null value is provided, then all action imports will be generated.DataModelGenerator
for chained method calls.protected File getInputDirectory()
protected File getOutputDirectory()
This is also the directory which gets cleared if the isDeleteTargetDirectory()
is set.
protected boolean isDeleteTargetDirectory()
#getOutputDirectory()
should be cleared before generating new
files.#getOutputDirectory()
should be cleared; false otherwise.protected boolean isForceFileOverride()
#getOutputDirectory()
can be
overridden.#getOutputDirectory()
can be overridden; false otherwise.protected String getPackageName()
This also builds a directory structure inside the getOutputDirectory()
.
@Nullable protected String getDefaultBasePath()
If no swagger file is given, this base path, together with the metadata file name, constitute the service path with the following pattern: <defaultBasePath> + <metadataFileNameWithoutExtension>.
protected File getServiceNameMappings()
If this file does not exist it will be created.
protected NamingStrategy getNamingStrategy()
Defaults to the DefaultNamingStrategy
class.
protected DefaultNamingStrategy.NameSource getNameSource()
DefaultNamingStrategy.NameSource
.
If getNamingStrategy()
returns the DefaultNamingStrategy
, this enum will be used to determine
the actual source of the java name.
NameSource
enum to be used by the DefaultNamingStrategy
.protected AnnotationStrategy getAnnotationStrategy()
Defaults to the DefaultAnnotationStrategy.
protected boolean isGeneratePojosOnly()
protected boolean isFailOnWarning()
protected String getExcludeFilePattern()
protected boolean isGenerateLinksToApiBusinessHub()
protected boolean isGenerateVersionReference()
protected String getCopyrightHeader()
protected Set<String> getIncludedEntitySets()
protected Set<String> getIncludedFunctionImports()
protected Set<String> getIncludedActionImports()
public void execute()
protected void printExecuteInformation()
public boolean failureDueToWarningsNecessary()
Copyright © 2020 SAP SE. All rights reserved.