GeneratedTypeBuilder
which is internal
* representation of the module
* @throws IllegalArgumentException
* if module is null
*/
- static GeneratedTypeBuilder moduleToDataType(final Module module, Mapmodule
.
* @throws IllegalArgumentException
* if module
is null
*/
- static GeneratedTypeBuilder moduleTypeBuilder(final Module module, final String postfix, final boolean verboseClassComments) {
+ static GeneratedTypeBuilder moduleTypeBuilder(final Module module, final String postfix, final boolean
+ verboseClassComments) {
Preconditions.checkArgument(module != null, "Module reference cannot be NULL.");
final String packageName = BindingMapping.getRootPackageName(module);
- final String moduleName = BindingMapping.getClassName(module.getName()) + postfix;
+ // underscore used as separator for distinction of module name parts
+ final String moduleName = new StringBuilder(module.getName()).append('_').append(postfix).toString();
final GeneratedTypeBuilderImpl moduleBuilder = new GeneratedTypeBuilderImpl(packageName, moduleName);
moduleBuilder.setDescription(createDescription(module, verboseClassComments));
moduleBuilder.setReference(module.getReference());
moduleBuilder.setModuleName(moduleName);
-
return moduleBuilder;
}
@@ -142,26 +172,23 @@ final class GenHelperUtil {
* @param builder
* builder to which are added implemented types according to
* dataNodeContainer
- * @param genCtx
+ * @param genCtx generated context
* @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(BindingGeneratorUtil.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.
@@ -228,34 +224,54 @@ final class GenHelperUtil {
* added to it.
*/
static GeneratedTypeBuilder resolveDataSchemaNodes(final Module module, final String basePackageName,
- final GeneratedTypeBuilder parent, final GeneratedTypeBuilder childOf, final IterablepackageName
and
* schemaNode
.
@@ -427,39 +398,102 @@ final class GenHelperUtil {
* 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 basePackageName
+ * string contains the module package name
* @param schemaNode
* schema node for which is created generated type builder
* @param parent
* parent type (can be null)
- * @param schemaContext
+ * @param schemaContext schema context
* @return generated type builder schemaNode
*/
- private static GeneratedTypeBuilder addDefaultInterfaceDefinition(final String packageName, final SchemaNode
- schemaNode, final Type parent, final Module module, MapschemaNode
with packageName
.
@@ -468,12 +502,11 @@ final class GenHelperUtil {
* {@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 basePackageName
+ * string contains the module package name
* @param schemaNode
* schema node which provide data about the schema node name
- * @param schemaContext
+ * @param schemaContext schema context
* @param prefix
* return type name prefix
* @return generated type builder for schemaNode
@@ -486,124 +519,769 @@ final class GenHelperUtil {
*
*
*/
- private static GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode,
- final SchemaContext schemaContext, final String prefix, final boolean verboseClassComments,
- MapchoiceNode
to the list of generated types for
+ * choice and its cases.
+ *
+ * The package names for choice and for its cases are created as
+ * concatenation of the module package (basePackageName
) and
+ * names of all parents node.
+ *
+ * @param module
+ * current module
+ * @param basePackageName
+ * string with the module package name
+ * @param parent
+ * parent type
+ * @param choiceNode
+ * choice node which is mapped to generated type. Also child
+ * nodes - cases are mapped to generated types.
+ * @throws IllegalArgumentException
+ * basePackageName
is nullchoiceNode
is nullleaf
to the getter method which is added to
+ * typeBuilder
.
+ *
+ * @param typeBuilder
+ * generated type builder to which is added getter method as
+ * leaf
mapping
+ * @param leaf
+ * leaf schema node which is mapped as getter method which is
+ * added to typeBuilder
+ * @param module
+ * Module in which type was defined
+ * @return boolean value
+ * leaf
or typeBuilder
are
+ * nullnode
leaf list schema node to getter method of
+ * typeBuilder
.
+ *
+ * @param typeBuilder
+ * generated type builder to which is node
added as
+ * getter method
+ * @param node
+ * leaf list schema node which is added to
+ * typeBuilder
as getter method
+ * @param module module
+ * @param typeProvider type provider instance
+ * @param genCtx actual generated context
+ * @return boolean value
+ * node
, typeBuilder
,
+ * nodeName equal null or node
is added by uses"); - 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(BindingGeneratorUtil.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 ListcaseNodes
set to list of corresponding generated
+ * types.
+ *
+ * For every case which isn't added through augment or uses is
+ * created generated type builder. The package names for the builder is
+ * created as concatenation of the module package (
+ * basePackageName
) and names of all parents nodes of the
+ * concrete case. There is also relation "implements type"
+ * between every case builder and choice type
+ *
+ * @param module
+ * current module
+ * @param schemaContext
+ * current schema context
+ * @param genCtx
+ * actual generated context
+ * @param basePackageName
+ * string with the module package name
+ * @param refChoiceType
+ * type which represents superior case
+ * @param choiceNode
+ * choice case node which is mapped to generated type
+ * @param verboseClassComments
+ * Javadoc verbosity switch
+ * @throws IllegalArgumentException
+ *
+ *
+ */
+ private static void generateTypesFromChoiceCases(final Module module, final SchemaContext schemaContext,
+ final MapbasePackageName
equals nullrefChoiceType
equals nullcaseNodes
equals nullschemaNode
to typeBuilder
as getter method
+ * or to genTOBuilder
as property.
+ *
+ * @param nodeName
+ * string contains the name of list
+ * @param basePackageName
+ * string contains the module package name
+ * @param schemaNode
+ * data schema node which should be added as getter method to
+ * typeBuilder
or as a property to
+ * genTOBuilder
if is part of the list key
+ * @param typeBuilder
+ * generated type builder for the list schema node
+ * @param genTOBuilder
+ * generated TO builder for the list keys
+ * @param listKeys
+ * list of string which contains QNames of the list keys
+ * @param module
+ * current module
+ * @param typeProvider
+ * provider that defines contract for generated types
+ * @param schemaContext
+ * schema context
+ * @param genCtx
+ * map of generated entities in context of YANG modules
+ * @param genTypeBuilders
+ * map of generated type builders
+ * @param verboseClassComments
+ * generate verbose comments
+ * @throws IllegalArgumentException
+ *
+ *
+ */
+ private static void addSchemaNodeToListBuilders(final String nodeName, final String basePackageName,
+ final DataSchemaNode schemaNode, final GeneratedTypeBuilder typeBuilder,
+ final GeneratedTOBuilder genTOBuilder, final ListschemaNode
equals nulltypeBuilder
equals nullType
objects. Firstly are groupings sorted according mutual
+ * dependencies. At least dependent (independent) groupings are in the list
+ * saved at first positions. For every grouping the record is added to map
+ * {@link ModuleContext#groupings allGroupings}
+ *
+ * @param module
+ * current module
+ * @param groupings
+ * collection of groupings from which types will be generated
+ * @param typeProvider
+ * provider that defines contract for generated types
+ * @param schemaContext
+ * schema context
+ * @param genCtx
+ * map of generated entities in context of YANG modules
+ * @param genTypeBuilders
+ * map of generated type builders
+ * @param verboseClassComments
+ * generate verbose comments
+ *
+ */
+ static MapGroupingDefinition
)
+ */
+ private static Map