...
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 | ||||
---|---|---|---|---|
|
The following options are available for the ADM code generation:
Command Line/Ant | Maven Plugin | Description | Default |
---|---|---|---|
-f, --file | modelFile | The input file specified either as OS path or URL | - |
-m, --modelsdir | modelsDirectory | Base directory for the | - |
-o, --outdir | projectOutputDirectory | Base output directory for the generated files. For maven plugin defaults to target/generated-[test]-sources/nvx-adm | - |
-c, --classesdir | classesOutputDirectory | Classes output folder (to which generated resoures should be copied). May be specified multiple times to copy to multiple directories. | - |
-e, --encoding | encodingType | Encoding type of content underlying the generated classes (Xbuf | Protobuf | Json) | Protobuf |
-x, --xpcompat | protoXbufGenerationCompatibility | Wire compatibility between protobuf and xbuf generated classes (None | Xbuf | Protobuf | Protobuf |
-y, --emptyifnullarray | generateArrayGetterEmptyIfNull | Instructs the code generator return empty arrays instead of null for unset array fields | false |
-n, --namespace | namespace | Namespace override of model parsed from the input file (overrides namespace in model file if supplied) | - |
-p, --protodir | N/A | An additonal directory in which to search for imported .proto files. | - |
-d, --directive | directives | A key=value pair specifying a code generation directive. (May be specified multiple times). See Directives below. | - |
-b, --buildinfo | buildInfo | String with build-time information such as project version, timestamp or machine. This is added to the AdmGenerated annotation of generated classes. | - |
-i, --incremental | incrementalBuild | Trigger incremental code generation - run only if something changed since last run | false (true for maven plugin) |
-u, --bundledir | modelBundleOutputDirectory | Directory to which to output model XML and IDL files if applicable | - |
N/A | useBasicDeltaDetection | When 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/A | generateModelBundle | Indicates whether models with all their dependencies and IDLs should be output to modelBundleOutputDirectory | false |
N/A | codegenListenerClassName | Class name of external listener to receive events from code generator. See ADM Code Generation Events. | - |
N/A | codegenListenerProperties | Additional properties to pass to the constructed code gen listener. | - |
Directives
Anchor | ||||
---|---|---|---|---|
|
...
Directive | Description | Default | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
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.
| false | ||||||||
generateDefaultGetters | Whether or not to generate default getters that accept a value to return when the field is not set. Not typically recommended | false | ||||||||
generateThrowOnUnsetGetters | Whether 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 | ||||||||
generateRequiredFieldValidators | Whether 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 | ||||||||
generateFluentSetters | Directive 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 | ||||||||
pooledStringFieldTypeNameSuffixPolicy | Can 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:
...