The Talon Manual

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Documenting ADM Code generator options

...

Code generation is accomplished using the ADMGenerator ADMCodeGenerator class distributed with the ADM module (nvx-adm-<vesion>.jar or the nvx-talon-all-<version>.jar). The XML schema is bundled in these jars at the jar root: /x-adml.xsd. 

...

Note

While it is legal to mix and match different encoding types within your application, it is isn't possible to mix and match encodings within a model via import. For example, if you generate one model with protobuf, it is not possible to use types already generated with protobuf in a model being generated with Xbuf.

Code Generator Options

Anchor
Options
Options

The following options are available for the ADM code generation: 

Command Line/AntMaven PluginDescriptionDefault
-f, --file

modelFile

The input file specified either as OS path or URL-
-m, --modelsdirmodelsDirectoryBase directory for the-
-o, --outdirprojectOutputDirectory

Base output directory for the generated files.

For maven plugin defaults to target/generated-[test]-sources/nvx-adm

-
-c, --classesdirclassesOutputDirectoryClasses output folder (to which generated resoures should be copied). May be specified multiple times to copy to multiple directories.-
-e, --encodingencodingTypeEncoding type of content underlying the generated classes (Xbuf | Protobuf | Json)Protobuf
-x, --xpcompatprotoXbufGenerationCompatibilityWire compatibility between protobuf and xbuf generated classes (None | Xbuf | ProtobufProtobuf
-y, --emptyifnullarraygenerateArrayGetterEmptyIfNullInstructs the code generator return empty arrays instead of null for unset array fieldsfalse
-n, --namespacenamespaceNamespace override of model parsed from the input file (overrides namespace in model file if supplied)-
-p, --protodirN/A

An additonal directory in which to search for imported .proto files.

-
-d, --directivedirectives

A key=value pair specifying a code generation directive. (May be specified multiple times).

See Directives below.

-
-b, --buildinfobuildInfoString with build-time information such as project version, timestamp or machine. This is added to the AdmGenerated annotation of generated classes.-
-i, --incrementalincrementalBuildTrigger incremental code generation - run only if something changed since last run

false

(true for maven plugin)

-u, --bundledirmodelBundleOutputDirectoryDirectory to which to output model XML and IDL files if applicable-
N/AuseBasicDeltaDetectionWhen running an incremental build, basic delta detection indicates that model's are rebuilt based on whether source model timestamp. With advanced delta detection dependencies are examined as well.false
N/AgenerateModelBundleIndicates whether models with all their dependencies and IDLs should be output to modelBundleOutputDirectoryfalse
N/AcodegenListenerClassNameClass name of external listener to receive events from code generator. See ADM Code Generation Events.-
N/AcodegenListenerPropertiesAdditional properties to pass to the constructed code gen listener.-

Directives

Anchor
Directives
Directives

...

DirectiveDescriptionDefault
generateEmbeddedEntityInterfaces

Directive indicating that the generator should create interfaces for embedded entities. This can be disabled for applications with stringent performance requirements to reduce the overhead associated with multi-morphic vtable lookups.

true
generateEmbeddedEntitiesNonFinal

When this directive is set to true the generated entity class is not declared as final nor are its accessors. This feature can be useful for applications that need to mock embedded entities in test frameworks such as CGLIB, but is not recommended for production use for performance reasons. 

Status
colourGreen
titleSince 3.8.189

false
generateDefaultGettersWhether or not to generate default getters that accept a value to return when the field is not set. Not typically recommendedfalse
generateThrowOnUnsetGettersWhether or not to generate getXXXOrThrow() or accessors that will throw an ERogFieldNotSetException when the field has not been set. This provides an alternate alternative to calling hasXXX for a field to test if the field is unset. Usage of this directive is not recommended; hasXXX is the recommended approach to testing if a field is not set. Exception throwing is more expensive, and the generated getXXXOrThrow method introduces extra invocation overhead and a larger code size.false
generateRequiredFieldValidatorsWhether or not validation logic is generated in the types validators for required fields. Enabling this leads large generated code size, and validation checks are expensive, so this is not recommended for performance sensitive applications.false
generateFluentSettersDirective indicating that fluent style setters should be generated for fields. This can be enabled to generate fluent accessors on generated types. This can be useful for writing concise testcodetest code, but is more overhead, so it's usage is not typically recommended.false

generateAllStringsPoolable

Directive indicating that all Strings fields in the model should be generated as poolable types regardless of the value of the field's poolable attribute.

false
pooledStringFieldTypeNameSuffixPolicyCan specify None, Always or OnConflict to instruct the code generator as to how to handle naming conflicts that arise from a pooled string field type name generated from a field name are suffixed to avoid a name clash."None"
pooledStringFieldTypeNameSuffix Specifies the suffic suffice to use to resolve pooled string type name conflicts with Always or OnConflict suffixing policies."String"

 


Running with

...

Java

To run the generator with java you can use:

...

The reason why this works is because that the result of running code generation would be:

...