GeneratedTypeBuilder
which is internal
* representation of the module
* @throws IllegalArgumentException
* if module is null
*/
static GeneratedTypeBuilder moduleToDataType(final Module module, Mapmodule
.
*
* @param module
* Module which is source of package name for generated type
* builder
* @param postfix
* string which is added to the module class name representation
* as suffix
* @param verboseClassComments
* @return instance of GeneratedTypeBuilder which represents
* module
.
* @throws IllegalArgumentException
* if module
is null
*/
static GeneratedTypeBuilder moduleTypeBuilder(final Module module, final String postfix, final boolean verboseClassComments) {
checkArgument(module != null, "Module reference cannot be NULL.");
final String packageName = Binding2Mapping.getRootPackageName(module);
final String moduleName = Binding2Mapping.getClassName(module.getName()) + postfix;
final GeneratedTypeBuilderImpl moduleBuilder = new GeneratedTypeBuilderImpl(packageName, moduleName);
moduleBuilder.setDescription(createDescription(module, verboseClassComments));
moduleBuilder.setReference(module.getReference());
moduleBuilder.setModuleName(moduleName);
return moduleBuilder;
}
/**
* Adds the implemented types to type builder.
*
* The method passes through the list of uses in
* {@code dataNodeContainer}. For every use is obtained corresponding
* generated type from all groupings
* allGroupings} which is added as implements type to
* builder
*
* @param dataNodeContainer
* element which contains the list of used YANG groupings
* @param builder
* builder to which are added implemented types according to
* dataNodeContainer
* @param genCtx
* @return generated type builder with all implemented types
*/
private static GeneratedTypeBuilder addImplementedInterfaceFromUses(final DataNodeContainer dataNodeContainer,
final GeneratedTypeBuilder builder, Map"); sb.append("This class represents the following YANG schema fragment defined in module "); sb.append(module.getName()); sb.append(""); sb.append(NEW_LINE); sb.append("
"); sb.append(NEW_LINE); sb.append(Binding2GeneratorUtil.encodeAngleBrackets(yangTemplateForModule.render(module).body())); sb.append(""); } return replaceAllIllegalChars(sb); } @VisibleForTesting public static String replaceAllIllegalChars(final StringBuilder stringBuilder){ final String ret = UNICODE_CHAR_PATTERN.matcher(stringBuilder).replaceAll("\\\\\\\\u"); return ret.isEmpty() ? "" : ret; } /** * Adds the methods to
typeBuilder
which represent subnodes of
* node for which typeBuilder
was created.
*
* The subnodes aren't mapped to the methods if they are part of grouping or
* augment (in this case are already part of them).
*
* @param module
* current module
* @param basePackageName
* string contains the module package name
* @param parent
* generated type builder which represents any node. The subnodes
* of this node are added to the typeBuilder
as
* methods. The subnode can be of type leaf, leaf-list, list,
* container, choice.
* @param childOf
* parent type
* @param schemaNodes
* set of data schema nodes which are the children of the node
* for which typeBuilder
was created
* @return generated type builder which is the same builder as input
* parameter. The getter methods (representing child nodes) could be
* added to it.
*/
static GeneratedTypeBuilder resolveDataSchemaNodes(final Module module, final String basePackageName,
final GeneratedTypeBuilder parent, final GeneratedTypeBuilder childOf, final IterabletypeBuilder
what represents subnodes of
* node for which typeBuilder
was created.
*
* @param module
* current module
* @param basePackageName
* string contains the module package name
* @param typeBuilder
* generated type builder which represents any node. The subnodes
* of this node are added to the typeBuilder
as
* methods. The subnode can be of type leaf, leaf-list, list,
* container, choice.
* @param childOf
* parent type
* @param schemaNodes
* set of data schema nodes which are the children of the node
* for which typeBuilder
was created
* @return generated type builder which is the same object as the input
* parameter typeBuilder
. The getter method could be
* added to it.
*/
private static GeneratedTypeBuilder augSchemaNodeToMethods(final Module module, final String basePackageName,
final GeneratedTypeBuilder typeBuilder, final GeneratedTypeBuilder childOf,
final IterablepackageName
and
* schemaNode
.
*
* The new builder always implements
* {@link org.opendaylight.mdsal.binding2.spec.TreeNode TreeNode}.schemaNode
is instance of GroupingDefinition it also
* implements {@link org.opendaylight.mdsal.binding2.spec.Augmentable
* Augmentable}.schemaNode
is instance of
* {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer
* DataNodeContainer} it can also implement nodes which are specified in
* uses.
*
* @param packageName
* string with the name of the package to which
* schemaNode
belongs.
* @param schemaNode
* schema node for which is created generated type builder
* @param parent
* parent type (can be null)
* @param schemaContext
* @return generated type builder schemaNode
*/
private static GeneratedTypeBuilder addDefaultInterfaceDefinition(final String packageName, final SchemaNode
schemaNode, final Type parent, final Module module, MapschemaNode
with packageName
.
*
* Firstly the generated type builder is searched in
* {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. If it isn't
* found it is created and added to genTypeBuilders
.
*
* @param packageName
* string with the package name to which returning generated type
* builder belongs
* @param schemaNode
* schema node which provide data about the schema node name
* @param schemaContext
* @param prefix
* return type name prefix
* @return generated type builder for schemaNode
* @throws IllegalArgumentException
* schemaNode
is nullpackageName
is null"); sb.append("This class represents the following YANG schema fragment defined in module "); sb.append(module.getName()); sb.append(""); sb.append(NEW_LINE); sb.append("
"); sb.append(NEW_LINE); sb.append(Binding2GeneratorUtil.encodeAngleBrackets(yangTemplateForNode.render(schemaNode).body())); sb.append(""); sb.append(NEW_LINE); sb.append("The schema path to identify an instance is"); sb.append(NEW_LINE); sb.append(""); sb.append(YangTextTemplate.formatSchemaPath(module.getName(), schemaNode.getPath().getPathFromRoot())); sb.append(""); sb.append(NEW_LINE); if (hasBuilderClass(schemaNode)) { sb.append(NEW_LINE); sb.append("
To create instances of this class use " + "{@link " + linkToBuilderClass + "}.");
sb.append(NEW_LINE);
sb.append("@see ");
sb.append(linkToBuilderClass);
sb.append(NEW_LINE);
if (schemaNode instanceof ListSchemaNode) {
final List