This fixes violations and flips enforcement on.
Change-Id: Ida4e62f4c3ddf4d7d8066f3858e6ab98f0f92cf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
private final Map<QNameModule, ModuleContext> genCtx = new HashMap<>();
/**
- * Outer key represents the package name. Outer value represents map of all
- * builders in the same package. Inner key represents the schema node name
- * (in JAVA class/interface name format). Inner value represents instance of
- * builder for schema node specified in key part.
+ * Outer key represents the package name. Outer value represents map of all builders in the same package. Inner key
+ * represents the schema node name (in JAVA class/interface name format). Inner value represents instance of builder
+ * for schema node specified in key part.
*/
private final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders = new HashMap<>();
private final AbstractTypeProvider typeProvider;
/**
- * Holds reference to schema context to resolve data of augmented element
- * when creating augmentation builder
+ * Holds reference to schema context to resolve data of augmented element when creating augmentation builder.
*/
private final SchemaContext schemaContext;
}
/**
- * Adds enumeration builder created from <code>enumTypeDef</code> to
- * <code>typeBuilder</code>.
+ * Adds enumeration builder created from <code>enumTypeDef</code> to <code>typeBuilder</code>. Each
+ * <code>enumTypeDef</code> item is added to builder with its name and value.
*
- * Each <code>enumTypeDef</code> item is added to builder with its name and
- * value.
- *
- * @param enumTypeDef
- * EnumTypeDefinition contains enum data
- * @param enumName
- * string contains name which will be assigned to enumeration
- * builder
- * @param typeBuilder
- * GeneratedTypeBuilder to which will be enum builder assigned
- * @param module
- * Module in which type should be generated
- * @return enumeration builder which contains data from
- * <code>enumTypeDef</code>
+ * @param enumTypeDef EnumTypeDefinition contains enum data
+ * @param enumName string contains name which will be assigned to enumeration builder
+ * @param typeBuilder GeneratedTypeBuilder to which will be enum builder assigned
+ * @param module Module in which type should be generated
+ * @return enumeration builder which contains data from <code>enumTypeDef</code>
*/
private EnumBuilder resolveInnerEnumFromTypeDefinition(final EnumTypeDefinition enumTypeDef, final QName enumName,
final GeneratedTypeBuilder typeBuilder, final ModuleContext context) {
/**
* Generates type builder for <code>module</code>.
*
- * @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
- * @return instance of GeneratedTypeBuilder which represents
- * <code>module</code>.
- * @throws IllegalArgumentException
- * if <code>module</code> is null
+ * @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
+ * @return instance of GeneratedTypeBuilder which represents <code>module</code>.
+ * @throws IllegalArgumentException if <code>module</code> is null
*/
private GeneratedTypeBuilder moduleTypeBuilder(final ModuleContext context, final String postfix) {
final Module module = context.module();
}
/**
- * Converts <code>augSchema</code> to list of <code>Type</code> which
- * contains generated type for augmentation. In addition there are also
- * generated types for all containers, list and choices which are child of
- * <code>augSchema</code> node or a generated types for cases are added if
- * augmented node is choice.
+ * Converts <code>augSchema</code> to list of <code>Type</code> which contains generated type for augmentation.
+ * In addition there are also generated types for all containers, list and choices which are child of
+ * <code>augSchema</code> node or a generated types for cases are added if augmented node is choice.
*
- * @param augmentPackageName
- * string with the name of the package to which the augmentation
- * belongs
- * @param augSchema
- * AugmentationSchema which is contains data about augmentation
- * (target path, childs...)
- * @param module
- * current module
+ * @param augmentPackageName string with the name of the package to which the augmentation belongs
+ * @param augSchema AugmentationSchema which is contains data about augmentation (target path, childs...)
+ * @param module current module
* @throws IllegalArgumentException
* <ul>
* <li>if <code>augmentPackageName</code> equals null</li>
/**
* Convenient method to find node added by uses statement.
*
- * @param targetPath
- * node path
- * @param parentUsesNode
- * parent of uses node
+ * @param targetPath node path
+ * @param parentUsesNode parent of uses node
* @return node from its original location in grouping
*/
private DataSchemaNode findOriginalTargetFromGrouping(final SchemaPath targetPath, final UsesNode parentUsesNode) {
}
/**
- * Returns a generated type builder for an augmentation.
- *
- * The name of the type builder is equal to the name of augmented node with
- * serial number as suffix.
+ * Returns a generated type builder for an augmentation. The name of the type builder is equal to the name
+ * of augmented node with serial number as suffix.
*
- * @param context
- * current module
- * @param augmentPackageName
- * string with contains the package name to which the augment
- * belongs
- * @param basePackageName
- * string with the package name to which the augmented node
- * belongs
- * @param targetTypeRef
- * target type
- * @param augSchema
- * augmentation schema which contains data about the child nodes
- * and uses of augment
+ * @param context current module
+ * @param augmentPackageName string with contains the package name to which the augment belongs
+ * @param basePackageName string with the package name to which the augmented node belongs
+ * @param targetTypeRef target type
+ * @param augSchema augmentation schema which contains data about the child nodes and uses of augment
* @return generated type builder for augment
*/
private GeneratedTypeBuilder addRawAugmentGenTypeDefinition(final ModuleContext context,
return addRawAugmentGenTypeDefinition(context, context.modulePackageName(), targetTypeRef, augSchema);
}
- /**
- *
- * @param unknownSchemaNodes
- * @return nodeParameter of UnknownSchemaNode
- */
private static String getAugmentIdentifier(final List<UnknownSchemaNode> unknownSchemaNodes) {
for (final UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) {
final QName nodeType = unknownSchemaNode.getNodeType();
}
/**
- * Returns first unique name for the augment generated type builder. The
- * generated type builder name for augment consists from name of augmented
- * node and serial number of its augmentation.
+ * Returns first unique name for the augment generated type builder. The generated type builder name for augment
+ * consists from name of augmented node and serial number of its augmentation.
*
- * @param builders
- * map of builders which were created in the package to which the
- * augmentation belongs
- * @param genTypeName
- * string with name of augmented node
+ * @param builders map of builders which were created in the package to which the augmentation belongs
+ * @param genTypeName string with name of augmented node
* @return string with unique name for augmentation builder
*/
private static String augGenTypeName(final Map<String, GeneratedTypeBuilder> builders, final String genTypeName) {
}
/**
- * Adds the methods to <code>typeBuilder</code> which represent subnodes of
- * node for which <code>typeBuilder</code> 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).
+ * Adds the methods to <code>typeBuilder</code> which represent subnodes of node for which <code>typeBuilder</code>
+ * 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 parent
- * generated type builder which represents any node. The subnodes
- * of this node are added to the <code>typeBuilder</code> 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 <code>typeBuilder</code> 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.
+ * @param module current module
+ * @param parent generated type builder which represents any node. The subnodes of this node are added
+ * to the <code>typeBuilder</code> 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
+ * <code>typeBuilder</code> 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.
*/
private GeneratedTypeBuilder resolveDataSchemaNodes(final ModuleContext context, final GeneratedTypeBuilder parent,
final @Nullable Type childOf, final Iterable<DataSchemaNode> schemaNodes) {
}
/**
- * Adds the methods to <code>typeBuilder</code> what represents subnodes of
- * node for which <code>typeBuilder</code> was created.
+ * Adds the methods to <code>typeBuilder</code> what represents subnodes of node for which <code>typeBuilder</code>
+ * was created.
*
- * @param module
- * current module
- * @param typeBuilder
- * generated type builder which represents any node. The subnodes
- * of this node are added to the <code>typeBuilder</code> 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 <code>typeBuilder</code> was created
- * @return generated type builder which is the same object as the input
- * parameter <code>typeBuilder</code>. The getter method could be
- * added to it.
+ * @param module current module
+ * @param typeBuilder generated type builder which represents any node. The subnodes of this node are added
+ * to the <code>typeBuilder</code> 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 <code>typeBuilder</code>
+ * was created
+ * @return generated type builder which is the same object as the input parameter <code>typeBuilder</code>.
+ * The getter method could be added to it.
*/
private GeneratedTypeBuilder augSchemaNodeToMethods(final ModuleContext context,
final GeneratedTypeBuilder typeBuilder, final Iterable<DataSchemaNode> schemaNodes) {
}
/**
- * Adds to <code>typeBuilder</code> a method which is derived from
- * <code>schemaNode</code>.
+ * Adds to <code>typeBuilder</code> a method which is derived from <code>schemaNode</code>.
*
- * @param node
- * data schema node which is added to <code>typeBuilder</code> as
- * a method
- * @param typeBuilder
- * generated type builder to which is <code>schemaNode</code>
- * added as a method.
- * @param childOf
- * parent type
- * @param module
- * current module
+ * @param node data schema node which is added to <code>typeBuilder</code> as a method
+ * @param typeBuilder generated type builder to which is <code>schemaNode</code> added as a method.
+ * @param childOf parent type
+ * @param module current module
*/
private void addSchemaNodeToBuilderAsMethod(final ModuleContext context, final DataSchemaNode node,
final GeneratedTypeBuilder typeBuilder, final Type baseInterface) {
}
/**
- * Converts <code>choiceNode</code> 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 (<code>basePackageName</code>) and
- * names of all parents node.
+ * Converts <code>choiceNode</code> 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 (<code>basePackageName</code>)
+ * and names of all parents node.
*
- * @param context
- * 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.
+ * @param context 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
* <ul>
* <li>if <code>basePackageName</code> is null</li>
}
/**
- * Converts <code>caseNodes</code> set to list of corresponding generated types.
- *
- * For every <i>case</i> which isn't added through augment or <i>uses</i> is created generated type builder.
- * The package names for the builder is created as concatenation of the module package and names of all parents
- * nodes of the concrete <i>case</i>. There is also relation "<i>implements type</i>" between every case builder
- * and <i>choice</i> type
+ * Converts <code>caseNodes</code> set to list of corresponding generated types. For every <i>case</i> which is not
+ * added through augment or <i>uses</i> is created generated type builder. The package names for the builder is
+ * created as concatenation of the module package and names of all parents nodes of the concrete <i>case</i>. There
+ * is also relation "<i>implements type</i>" between every case builder and <i>choice</i> type
*
- * @param context
- * current module context
- * @param refChoiceType
- * type which represents superior <i>case</i>
- * @param choiceNode
- * choice case node which is mapped to generated type
+ * @param context current module context
+ * @param refChoiceType type which represents superior <i>case</i>
+ * @param choiceNode choice case node which is mapped to generated type
* @throws IllegalArgumentException
* <ul>
* <li>if <code>refChoiceType</code> equals null</li>
} else {
resolveDataSchemaNodes(context, caseTypeBuilder, moduleToDataType(context), caseChildNodes);
}
- }
+ }
}
processUsesAugments(caseNode, context);
}
}
/**
- * Generates list of generated types for all the cases of a choice which are
- * added to the choice through the augment.
+ * Generates list of generated types for all the cases of a choice which are added to the choice through
+ * the augment.
*
- * @param module
- * current module
- * @param basePackageName
- * string contains name of package to which augment belongs. If
- * an augmented choice is from an other package (pcg1) than an
- * augmenting choice (pcg2) then case's of the augmenting choice
- * will belong to pcg2.
- * @param targetType
- * Type which represents target choice
- * @param targetNode
- * node which represents target choice
- * @param augmentedNodes
- * set of choice case nodes for which is checked if are/aren't
- * added to choice through augmentation
+ * @param module current module
+ * @param basePackageName string contains name of package to which augment belongs. If an augmented choice is
+ * from an other package (pcg1) than an augmenting choice (pcg2) then case's
+ * of the augmenting choice will belong to pcg2.
+ * @param targetType Type which represents target choice
+ * @param targetNode node which represents target choice
+ * @param augmentedNodes set of choice case nodes for which is checked if are/are not added to choice through
+ * augmentation
* @throws IllegalArgumentException
* <ul>
* <li>if <code>basePackageName</code> is null</li>
}
/**
- * Converts <code>leaf</code> to the getter method which is added to
- * <code>typeBuilder</code>.
+ * Converts <code>leaf</code> to the getter method which is added to <code>typeBuilder</code>.
*
- * @param typeBuilder
- * generated type builder to which is added getter method as
- * <code>leaf</code> mapping
- * @param leaf
- * leaf schema node which is mapped as getter method which is
- * added to <code>typeBuilder</code>
- * @param module
- * Module in which type was defined
+ * @param typeBuilder generated type builder to which is added getter method as <code>leaf</code> mapping
+ * @param leaf leaf schema node which is mapped as getter method which is added to <code>typeBuilder</code>
+ * @param module Module in which type was defined
* @return boolean value
* <ul>
* <li>false - if <code>leaf</code> or <code>typeBuilder</code> are
}
/**
- * Converts <code>leaf</code> schema node to property of generated TO
- * builder.
+ * Converts <code>leaf</code> schema node to property of generated TO builder.
*
- * @param toBuilder
- * generated TO builder to which is <code>leaf</code> added as
- * property
- * @param leaf
- * leaf schema node which is added to <code>toBuilder</code> as
- * property
- * @param returnType
- * property type
- * @param isReadOnly
- * boolean value which says if leaf property is|isn't read only
+ * @param toBuilder generated TO builder to which is <code>leaf</code> added as property
+ * @param leaf leaf schema node which is added to <code>toBuilder</code> as property
+ * @param returnType property type
+ * @param isReadOnly boolean value which says if leaf property is|isn't read only
* @return boolean value
* <ul>
* <li>false - if <code>leaf</code>, <code>toBuilder</code> or leaf
}
/**
- * Converts <code>node</code> leaf list schema node to getter method of
- * <code>typeBuilder</code>.
+ * Converts <code>node</code> leaf list schema node to getter method of <code>typeBuilder</code>.
*
- * @param typeBuilder
- * generated type builder to which is <code>node</code> added as
- * getter method
- * @param node
- * leaf list schema node which is added to
- * <code>typeBuilder</code> as getter method
+ * @param typeBuilder generated type builder to which is <code>node</code> added as getter method
+ * @param node leaf list schema node which is added to <code>typeBuilder</code> as getter method
* @param module module
* @return boolean value
* <ul>
}
/**
- * Instantiates generated type builder with <code>packageName</code> and
- * <code>schemaNode</code>.
- *
- * The new builder always implements
- * {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.<br>
- * If <code>schemaNode</code> is instance of GroupingDefinition it also
- * implements {@link org.opendaylight.yangtools.yang.binding.Augmentable
- * Augmentable}.<br>
+ * Instantiates generated type builder with <code>packageName</code> and <code>schemaNode</code>. The new builder
+ * always implements {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.<br>
+ * If <code>schemaNode</code> is instance of GroupingDefinition it also implements
+ * {@link org.opendaylight.yangtools.yang.binding.Augmentable Augmentable}.<br>
* If <code>schemaNode</code> is instance of
- * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer
- * DataNodeContainer} it can also implement nodes which are specified in
- * <i>uses</i>.
+ * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer DataNodeContainer} it can also implement nodes
+ * which are specified in <i>uses</i>.
*
- * @param packageName
- * string with the name of the package to which
- * <code>schemaNode</code> belongs.
- * @param schemaNode
- * schema node for which is created generated type builder
- * @param parent
- * parent type (can be null)
+ * @param packageName string with the name of the package to which <code>schemaNode</code> belongs.
+ * @param schemaNode schema node for which is created generated type builder
+ * @param parent parent type (can be null)
* @return generated type builder <code>schemaNode</code>
*/
private GeneratedTypeBuilder addDefaultInterfaceDefinition(final String packageName, final SchemaNode schemaNode,
/**
* Wraps the calling of the same overloaded method.
*
- * @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 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
* @return generated type builder for <code>schemaNode</code>
*/
private GeneratedTypeBuilder addRawInterfaceDefinition(final ModuleContext context, final SchemaNode schemaNode,
}
/**
- * Returns reference to generated type builder for specified
- * <code>schemaNode</code> with <code>packageName</code>.
- *
- * Firstly the generated type builder is searched in
- * {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. If it isn't
- * found it is created and added to <code>genTypeBuilders</code>.
+ * Returns reference to generated type builder for specified <code>schemaNode</code> with <code>packageName</code>.
+ * Firstly the generated type builder is searched in {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}.
+ * If it is not found it is created and added to <code>genTypeBuilders</code>.
*
- * @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 prefix
- * return type name prefix
+ * @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 prefix return type name prefix
* @return generated type builder for <code>schemaNode</code>
* @throws IllegalArgumentException
* <ul>
* <li>if QName of schema node is null</li>
* <li>if schemaNode name is null</li>
* </ul>
- *
*/
private GeneratedTypeBuilder addRawInterfaceDefinition(final JavaTypeName identifier, final SchemaNode schemaNode) {
checkArgument(schemaNode != null, "Data Schema Node cannot be NULL.");
/**
* Creates the name of the getter method name from <code>localName</code>.
*
- * @param localName
- * string with the name of the getter method
- * @param returnType
- * return type
- * @return string with the name of the getter method for
- * <code>methodName</code> in JAVA method format
+ * @param localName string with the name of the getter method
+ * @param returnType return type
+ * @return string with the name of the getter method for <code>methodName</code> in JAVA method format
*/
public static String getterMethodName(final String localName, final Type returnType) {
final StringBuilder method = new StringBuilder();
}
/**
- * Created a method signature builder as part of <code>interfaceBuilder</code>.
- *
- * The method signature builder is created for the getter method of <code>schemaNodeName</code>.
- * Also <code>comment</code> and <code>returnType</code> information are added to the builder.
+ * Created a method signature builder as part of <code>interfaceBuilder</code>. The method signature builder is
+ * created for the getter method of <code>schemaNodeName</code>. Also <code>comment</code>
+ * and <code>returnType</code> information are added to the builder.
*
* @param interfaceBuilder generated type builder for which the getter method should be created
* @param returnType type which represents the return type of the getter method
}
/**
- * Adds <code>schemaNode</code> to <code>typeBuilder</code> as getter method
- * or to <code>genTOBuilder</code> as property.
+ * Adds <code>schemaNode</code> to <code>typeBuilder</code> as getter method or to <code>genTOBuilder</code>
+ * as a property.
*
- * @param basePackageName
- * string contains the module package name
- * @param schemaNode
- * data schema node which should be added as getter method to
- * <code>typeBuilder</code> or as a property to
- * <code>genTOBuilder</code> 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 names of the list keys
- * @param module
- * current module
+ * @param basePackageName string contains the module package name
+ * @param schemaNode data schema node which should be added as getter method to <code>typeBuilder</code>
+ * or as a property to <code>genTOBuilder</code> 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 names of the list keys
+ * @param module current module
* @throws IllegalArgumentException
* <ul>
* <li>if <code>schemaNode</code> equals null</li>
}
/**
- * Selects the names of the list keys from <code>list</code> and returns
- * them as the list of the strings
+ * Selects the names of the list keys from <code>list</code> and returns them as the list of the strings.
*
- * @param list
- * of string with names of the list keys
- * @return list of string which represents names of the list keys. If the
- * <code>list</code> contains no keys then the empty list is
- * returned.
+ * @param list of string with names of the list keys
+ * @return list of string which represents names of the list keys. If the <code>list</code> contains no keys then
+ * an empty list is returned.
*/
private static List<String> listKeys(final ListSchemaNode list) {
final List<String> listKeys = new ArrayList<>();
}
/**
- * Generates for the <code>list</code> which contains any list keys special
- * generated TO builder.
+ * Generates for the <code>list</code> which contains any list keys special generated TO builder.
*
- * @param packageName
- * string with package name to which the list belongs
- * @param list
- * list schema node which is source of data about the list name
- * @return generated TO builder which represents the keys of the
- * <code>list</code> or null if <code>list</code> is null or list of
- * key definitions is null or empty.
+ * @param packageName string with package name to which the list belongs
+ * @param list list schema node which is source of data about the list name
+ * @return generated TO builder which represents the keys of the <code>list</code> or null if <code>list</code> is
+ * null or list of key definitions is null or empty.
*/
private GeneratedTOBuilder resolveListKeyTOBuilder(final ModuleContext context, final ListSchemaNode list) {
if (list.getKeyDefinition() != null && !list.getKeyDefinition().isEmpty()) {
}
/**
- * Builds a GeneratedTOBuilder for a UnionType {@link UnionTypeDefinition}.
- *
- * If more then one generated TO builder is created for enclosing then all
- * of the generated TO builders are added to <code>typeBuilder</code> as
+ * Builds a GeneratedTOBuilder for a UnionType {@link UnionTypeDefinition}. If more then one generated TO builder
+ * is created for enclosing then all of the generated TO builders are added to <code>typeBuilder</code> as
* enclosing transfer objects.
*
- * @param typeDef
- * type definition which can be of type <code>UnionType</code> or
- * <code>BitsTypeDefinition</code>
- * @param typeBuilder
- * generated type builder to which is added generated TO created
- * from <code>typeDef</code>
- * @param leaf
- * string with name for generated TO builder
- * @param parentModule
- * parent module
+ * @param typeDef type definition which can be of type <code>UnionType</code> or <code>BitsTypeDefinition</code>
+ * @param typeBuilder generated type builder to which is added generated TO created from <code>typeDef</code>
+ * @param leaf string with name for generated TO builder
+ * @param parentModule parent module
* @return generated TO builder for <code>typeDef</code>
*/
private Type addTOToTypeBuilder(final UnionTypeDefinition typeDef,
}
/**
- * Builds generated TO builders for <code>typeDef</code> of type {@link BitsTypeDefinition} which are
- * also added to <code>typeBuilder</code> as enclosing transfer object.
+ * Builds generated TO builders for <code>typeDef</code> of type {@link BitsTypeDefinition} which are also added
+ * to <code>typeBuilder</code> as enclosing transfer object. If more then one generated TO builder is created
+ * for enclosing then all of the generated TO builders are added to <code>typeBuilder</code> as enclosing transfer
+ * objects.
*
- * If more then one generated TO builder is created for enclosing then all
- * of the generated TO builders are added to <code>typeBuilder</code> as
- * enclosing transfer objects.
- *
- * @param typeDef
- * type definition which can be of type <code>UnionType</code> or
- * <code>BitsTypeDefinition</code>
- * @param typeBuilder
- * generated type builder to which is added generated TO created
- * from <code>typeDef</code>
- * @param leaf
- * string with name for generated TO builder
- * @param parentModule
- * parent module
+ * @param typeDef type definition which can be of type <code>UnionType</code> or <code>BitsTypeDefinition</code>
+ * @param typeBuilder generated type builder to which is added generated TO created from <code>typeDef</code>
+ * @param leaf string with name for generated TO builder
+ * @param parentModule parent module
* @return generated TO builder for <code>typeDef</code>
*/
private GeneratedTOBuilder addTOToTypeBuilder(final BitsTypeDefinition typeDef,
}
/**
- * Adds the implemented types to type builder.
- *
- * The method passes through the list of <i>uses</i> in
- * {@code dataNodeContainer}. For every <i>use</i> is obtained corresponding
- * generated type from {@link ModuleContext#groupings
- * allGroupings} which is added as <i>implements type</i> to
- * <code>builder</code>
+ * Adds the implemented types to type builder. The method passes through the list of <i>uses</i> in
+ * {@code dataNodeContainer}. For every <i>use</i> is obtained corresponding generated type
+ * from {@link ModuleContext#groupings allGroupings} which is added as <i>implements type</i>
+ * to <code>builder</code>
*
- * @param dataNodeContainer
- * element which contains the list of used YANG groupings
- * @param builder
- * builder to which are added implemented types according to
- * <code>dataNodeContainer</code>
+ * @param dataNodeContainer element which contains the list of used YANG groupings
+ * @param builder builder to which are added implemented types according to <code>dataNodeContainer</code>
* @return generated type builder with all implemented types
*/
private GeneratedTypeBuilder addImplementedInterfaceFromUses(final DataNodeContainer dataNodeContainer,
private static final Logger LOG = LoggerFactory.getLogger(BindingGeneratorImpl.class);
/**
- * Resolves generated types from <code>context</code> schema nodes only for
- * modules specified in <code>modules</code>
+ * Resolves generated types from <code>context</code> schema nodes only for modules specified
+ * in <code>modules</code>. Generated types are created for modules, groupings, types, containers, lists, choices,
+ * augments, rpcs, notification, identities.
*
- * Generated types are created for modules, groupings, types, containers,
- * lists, choices, augments, rpcs, notification, identities.
- *
- * @param context
- * schema context which contains data about all schema nodes
- * saved in modules
- * @param modules
- * set of modules for which schema nodes should be generated
- * types
+ * @param context schema context which contains data about all schema nodes saved in modules
+ * @param modules set of modules for which schema nodes should be generated types
* @return list of types (usually <code>GeneratedType</code> or
* <code>GeneratedTransferObject</code>) which:
* <ul>
checkState(context.getModules() != null, "Schema Context does not contain defined modules.");
}
- private static void rename(final Map<SchemaNode, JavaTypeName> renames, final RenameMappingException e) {
- final JavaTypeName name = e.getName();
- final SchemaNode def = e.getDefinition();
+ private static void rename(final Map<SchemaNode, JavaTypeName> renames, final RenameMappingException ex) {
+ final JavaTypeName name = ex.getName();
+ final SchemaNode def = ex.getDefinition();
final JavaTypeName existing = renames.get(def);
if (existing != null) {
throw new IllegalStateException("Attempted to relocate " + def + " to " + name + ", already remapped to "
- + existing, e);
+ + existing, ex);
}
final String suffix;
} else if (def instanceof TypeDefinition) {
suffix = "$T";
} else {
- throw new IllegalStateException("Unhandled remapping of " + def + " at " + name, e);
+ throw new IllegalStateException("Unhandled remapping of " + def + " at " + name, ex);
}
final JavaTypeName newName = name.createSibling(name.simpleName() + suffix);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.mdsal.binding.generator.impl;
import com.google.common.base.Preconditions;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class BindingSchemaContextUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(BindingSchemaContextUtils.class);
private BindingSchemaContextUtils() {
throw new UnsupportedOperationException("Utility class should not be instantiated");
currentContainer = findNotification(ctx, currentQName);
} else if (BindingReflections.isRpcType(currentArg.getType())) {
currentContainer = findFirstDataNodeContainerInRpc(ctx, currentArg.getType());
- if(currentQName == null && currentContainer.isPresent()) {
+ if (currentQName == null && currentContainer.isPresent()) {
currentQName = ((DataSchemaNode) currentContainer.get()).getQName();
}
} else {
currentArg = pathArguments.next();
if (Augmentation.class.isAssignableFrom(currentArg.getType())) {
currentQName = BindingReflections.findQName(currentArg.getType());
- if(pathArguments.hasNext()) {
+ if (pathArguments.hasNext()) {
currentArg = pathArguments.next();
} else {
return currentContainer;
}
}
- if(ChildOf.class.isAssignableFrom(currentArg.getType()) && BindingReflections.isAugmentationChild(currentArg.getType())) {
+ if (ChildOf.class.isAssignableFrom(currentArg.getType())
+ && BindingReflections.isAugmentationChild(currentArg.getType())) {
currentQName = BindingReflections.findQName(currentArg.getType());
} else {
currentQName = BindingReflections.findQName(currentArg.getType()).withModule(currentQName.getModule());
return currentContainer;
}
- private static Optional<DataNodeContainer> findNotification(final SchemaContext ctx, final QName notificationQName) {
- for (NotificationDefinition notification : ctx.getNotifications()) {
- if (notification.getQName().equals(notificationQName)) {
- return Optional.<DataNodeContainer> of(notification);
- }
- }
- return Optional.empty();
- }
-
private static Optional<DataNodeContainer> findDataNodeContainer(final DataNodeContainer ctx,
final QName targetQName) {
return Optional.empty();
}
+ private static Optional<DataNodeContainer> findNotification(final SchemaContext ctx,
+ final QName notificationQName) {
+ for (NotificationDefinition notification : ctx.getNotifications()) {
+ if (notification.getQName().equals(notificationQName)) {
+ return Optional.of(notification);
+ }
+ }
+ return Optional.empty();
+ }
+
private static DataNodeContainer findInCases(final ChoiceSchemaNode choiceNode, final QName targetQName) {
for (CaseSchemaNode caze : choiceNode.getCases().values()) {
Optional<DataNodeContainer> potential = findDataNodeContainer(caze, targetQName);
return null;
}
+ @SuppressWarnings("checkstyle:illegalCatch")
private static Optional<DataNodeContainer> findFirstDataNodeContainerInRpc(final SchemaContext ctx,
final Class<? extends DataObject> targetType) {
final QNameModule targetModule;
if (targetType.equals(rpcOutputName)) {
return Optional.of(rpc.getOutput());
}
- return Optional.empty();
+ return Optional.empty();
}
public static Set<AugmentationSchemaNode> collectAllAugmentationDefinitions(final SchemaContext currentSchema,
final AugmentationTarget ctxNode) {
HashSet<AugmentationSchemaNode> augmentations = new HashSet<>();
augmentations.addAll(ctxNode.getAvailableAugmentations());
- if(ctxNode instanceof DataSchemaNode && ((DataSchemaNode) ctxNode).isAddedByUses()) {
-
- System.out.println(ctxNode);
-
+ if (ctxNode instanceof DataSchemaNode && ((DataSchemaNode) ctxNode).isAddedByUses()) {
+ LOG.info("{}", ctxNode);
}
return augmentations;
public static Optional<CaseSchemaNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice,
final CaseSchemaNode originalDefinition) {
CaseSchemaNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName());
- if(originalDefinition.equals(potential)) {
+ if (originalDefinition.equals(potential)) {
return Optional.of(potential);
}
if (potential != null) {
return moduleNode;
}
- public GeneratedTypeBuilder getChildNode(final SchemaPath p) {
- return childNodes.get(p);
+ public GeneratedTypeBuilder getChildNode(final SchemaPath path) {
+ return childNodes.get(path);
}
- public GeneratedTypeBuilder getGrouping(final SchemaPath p) {
- return groupings.get(p);
+ public GeneratedTypeBuilder getGrouping(final SchemaPath path) {
+ return groupings.get(path);
}
- public GeneratedTypeBuilder getCase(final SchemaPath p) {
- return cases.get(p);
+ public GeneratedTypeBuilder getCase(final SchemaPath path) {
+ return cases.get(path);
}
- public void addModuleNode(final GeneratedTypeBuilder moduleNode) {
- this.moduleNode = moduleNode;
+ public void addModuleNode(final GeneratedTypeBuilder newModuleNode) {
+ this.moduleNode = newModuleNode;
}
- public void addGeneratedTOBuilder(final GeneratedTOBuilder b) {
- genTOs.add(b);
+ public void addGeneratedTOBuilder(final GeneratedTOBuilder builder) {
+ genTOs.add(builder);
}
- public void addChildNodeType(final SchemaNode def, final GeneratedTypeBuilder b) {
- checkNamingConflict(def, b.getIdentifier());
- childNodes.put(def.getPath(), b);
- typeToSchema.put(b, def);
+ public void addChildNodeType(final SchemaNode def, final GeneratedTypeBuilder builder) {
+ checkNamingConflict(def, builder.getIdentifier());
+ childNodes.put(def.getPath(), builder);
+ typeToSchema.put(builder, def);
}
- public void addGroupingType(final GroupingDefinition def, final GeneratedTypeBuilder b) {
- checkNamingConflict(def, b.getIdentifier());
- groupings.put(def.getPath(), b);
+ public void addGroupingType(final GroupingDefinition def, final GeneratedTypeBuilder builder) {
+ checkNamingConflict(def, builder.getIdentifier());
+ groupings.put(def.getPath(), builder);
}
- public void addTypedefType(final TypeDefinition<?> def, final Type t) {
- final JavaTypeName name = t.getIdentifier();
+ public void addTypedefType(final TypeDefinition<?> def, final Type type) {
+ final JavaTypeName name = type.getIdentifier();
final SchemaNode existingDef = nameMapping.putIfAbsent(name, def);
if (existingDef != null) {
if (!(existingDef instanceof TypeDefinition)) {
LOG.debug("GeneratedType conflict between {} and {} on {}", def, existingDef, name);
}
- typedefs.put(def.getPath(), t);
+ typedefs.put(def.getPath(), type);
}
- public void addCaseType(final SchemaPath p, final GeneratedTypeBuilder b) {
- cases.put(p, b);
+ public void addCaseType(final SchemaPath path, final GeneratedTypeBuilder builder) {
+ cases.put(path, builder);
}
- public void addIdentityType(final IdentitySchemaNode def, final GeneratedTypeBuilder b) {
- checkNamingConflict(def, b.getIdentifier());
- identities.put(def.getQName(), b);
+ public void addIdentityType(final IdentitySchemaNode def, final GeneratedTypeBuilder builder) {
+ checkNamingConflict(def, builder.getIdentifier());
+ identities.put(def.getQName(), builder);
}
- public void addTopLevelNodeType(final GeneratedTypeBuilder b) {
- topLevelNodes.add(b);
+ public void addTopLevelNodeType(final GeneratedTypeBuilder builder) {
+ topLevelNodes.add(builder);
}
- public void addAugmentType(final GeneratedTypeBuilder b) {
- augmentations.add(b);
+ public void addAugmentType(final GeneratedTypeBuilder builder) {
+ augmentations.add(builder);
}
public Map<SchemaPath, Type> getTypedefs() {
}
/**
- * Returns mapping of type to its schema.
- *
- * Valid values are only instances of {@link DataSchemaNode} or {@link AugmentationSchemaNode}
+ * Returns mapping of type to its schema. Valid values are only instances of {@link DataSchemaNode}
+ * or {@link AugmentationSchemaNode}.
*
* @return Mapping from type to corresponding schema
*/
/**
* Adds mapping between schema path and an inner type.
- *
- * @param path
- * @param type
*/
void addInnerTypedefType(final SchemaPath path, final Type type) {
innerTypes.put(path, type);
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy
+public final class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy
implements ModuleInfoRegistry, SchemaContextProvider, SchemaSourceProvider<YangTextSchemaSource> {
private final YangTextSchemaContextResolver ctxResolver = YangTextSchemaContextResolver.create("binding-context");
return ctxResolver.getSchemaContext();
}
+ @SuppressWarnings("checkstyle:illegalCatch")
private boolean resolveModuleInfo(final Class<?> cls) {
try {
return resolveModuleInfo(BindingReflections.getModuleInfo(cls));
}
}
+ @SuppressWarnings("checkstyle:illegalCatch")
private boolean resolveModuleInfo(final YangModuleInfo moduleInfo) {
SourceIdentifier identifier = sourceIdentifierFrom(moduleInfo);
private final ModuleInfoBackedContext context;
- public YangModuleInfoRegistration(final YangModuleInfo instance, final ModuleInfoBackedContext context) {
+ YangModuleInfoRegistration(final YangModuleInfo instance, final ModuleInfoBackedContext context) {
super(instance);
this.context = context;
}
final class TransformerGeneratorException extends RuntimeException {
private static final long serialVersionUID = 1L;
- public TransformerGeneratorException(final String message, final Throwable cause) {
+ TransformerGeneratorException(final String message, final Throwable cause) {
super(message, cause);
}
- public static TransformerGeneratorException wrap(final Class<?> cls, final Throwable cause) throws TransformerGeneratorException {
+ static TransformerGeneratorException wrap(final Class<?> cls, final Throwable cause)
+ throws TransformerGeneratorException {
return new TransformerGeneratorException(String.format("Failed to generate for type %s", cls), cause);
}
}
return found;
}
- private static Type referencedType(final Class<?> type) {
- return new ReferencedTypeImpl(JavaTypeName.create(type));
- }
-
/**
* Returns schema ({@link DataSchemaNode}, {@link AugmentationSchemaNode} or {@link TypeDefinition})
* from which supplied class was generated. Returned schema may be augmented with
return getEnumMapping(findTypeWithSchema(enumClassName));
}
+ private static BiMap<String, String> getEnumMapping(final Entry<GeneratedType, WithStatus> typeWithSchema) {
+ final TypeDefinition<?> typeDef = (TypeDefinition<?>) typeWithSchema.getValue();
+
+ Preconditions.checkArgument(typeDef instanceof EnumTypeDefinition);
+ final EnumTypeDefinition enumType = (EnumTypeDefinition) typeDef;
+
+ final HashBiMap<String, String> mappedEnums = HashBiMap.create();
+
+ for (final EnumTypeDefinition.EnumPair enumPair : enumType.getValues()) {
+ mappedEnums.put(enumPair.getName(), BindingMapping.getClassName(enumPair.getName()));
+ }
+
+ // TODO cache these maps for future use
+ return mappedEnums;
+ }
+
private Entry<GeneratedType, WithStatus> findTypeWithSchema(final String className) {
// All we have is a straight FQCN, which we need to split into a hierarchical JavaTypeName. This involves
// some amount of guesswork -- we do that by peeling components at the dot and trying out, e.g. given
throw new IllegalArgumentException("Failed to find type for " + className);
}
- private static BiMap<String, String> getEnumMapping(final Entry<GeneratedType, WithStatus> typeWithSchema) {
- final TypeDefinition<?> typeDef = (TypeDefinition<?>) typeWithSchema.getValue();
-
- Preconditions.checkArgument(typeDef instanceof EnumTypeDefinition);
- final EnumTypeDefinition enumType = (EnumTypeDefinition) typeDef;
-
- final HashBiMap<String, String> mappedEnums = HashBiMap.create();
-
- for (final EnumTypeDefinition.EnumPair enumPair : enumType.getValues()) {
- mappedEnums.put(enumPair.getName(), BindingMapping.getClassName(enumPair.getName()));
- }
-
- // TODO cache these maps for future use
- return mappedEnums;
- }
-
public Set<Class<?>> getCases(final Class<?> choice) {
final Collection<Type> cazes = runtimeTypes.findCases(referencedType(choice));
final Set<Class<?>> ret = new HashSet<>(cazes.size());
return new AugmentationIdentifier(childNames);
}
+ private static Type referencedType(final Class<?> type) {
+ return new ReferencedTypeImpl(JavaTypeName.create(type));
+ }
+
private static Type referencedType(final Type type) {
if (type instanceof ReferencedTypeImpl) {
return type;
*/
package org.opendaylight.mdsal.binding.generator.util;
-public class CodeGenerationException extends RuntimeException{
+public class CodeGenerationException extends RuntimeException {
private static final long serialVersionUID = 1L;
public CodeGenerationException() {
}
- public CodeGenerationException(String message, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace) {
+ public CodeGenerationException(final String message, final Throwable cause, final boolean enableSuppression,
+ final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
- public CodeGenerationException(String message, Throwable cause) {
+ public CodeGenerationException(final String message, final Throwable cause) {
super(message, cause);
}
- public CodeGenerationException(String message) {
+ public CodeGenerationException(final String message) {
super(message);
}
- public CodeGenerationException(Throwable cause) {
+ public CodeGenerationException(final Throwable cause) {
super(cause);
}
}
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import javassist.CtClass;
import javassist.CtField;
import javassist.CtMethod;
import javassist.Modifier;
import javassist.NotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The default implementation of the SourceCodeGenerator interface that generates readable source code
* is obtained from a system property (<i>org.opendaylight.yangtools.sal.generatedCodecSourceDir</i>) or
* defaults to "generated-codecs".
*/
- public DefaultSourceCodeGenerator(String generatedSourceDir) {
- if(generatedSourceDir != null) {
+ public DefaultSourceCodeGenerator(final String generatedSourceDir) {
+ if (generatedSourceDir != null) {
this.generatedSourceDir = generatedSourceDir;
- }
- else {
+ } else {
this.generatedSourceDir = System.getProperty(GENERATED_SOURCE_DIR_PROP, "generated-codecs");
}
}
@Override
- public void appendField(CtField field, String value) {
+ public void appendField(final CtField field, final String value) {
try {
builder.append('\n')
.append(Modifier.toString(field.getModifiers()))
}
@Override
- public void appendMethod(CtMethod method, String code) {
+ public void appendMethod(final CtMethod method, final String code) {
try {
builder.append('\n')
.append(Modifier.toString(method.getModifiers()))
}
@Override
- public void outputGeneratedSource(CtClass ctClass) {
+ public void outputGeneratedSource(final CtClass ctClass) {
String name = ctClass.getName();
StringBuilder classBuilder = new StringBuilder();
* @throws NotFoundException when the prototype class is not found
*/
@Beta
+ @SuppressWarnings("checkstyle:illegalCatch")
public synchronized CtClass instantiatePrototype(final String prototype, final String fqn,
final ClassCustomizer customizer) throws CannotCompileException, NotFoundException {
final CtClass result = classPool.getAndRename(prototype, fqn);
/**
* Gets a SourceCodeGenerator instance.
+ *
* <p>
* Generation of source code is controlled by the <i>org.opendaylight.yangtools.sal.generateCodecSource</i>
* system property. If set to true, a DefaultSourceCodeGenerator instance is returned, otherwise a
}
public static QName getAugmentationIdentifier(final AugmentationSchemaNode augmentation) {
- for(final UnknownSchemaNode extension : augmentation.getUnknownSchemaNodes()) {
- if(AUGMENT_IDENTIFIER.equals(extension.getNodeType().getLocalName())) {
+ for (final UnknownSchemaNode extension : augmentation.getUnknownSchemaNodes()) {
+ if (AUGMENT_IDENTIFIER.equals(extension.getNodeType().getLocalName())) {
return extension.getQName();
}
}
QName currentArg = arguments.next();
DataNodeContainer currentNode = context.findModule(currentArg.getModule()).orElse(null);
- if(currentNode == null) {
+ if (currentNode == null) {
return null;
}
// Last argument is type definition, so we need to cycle until we hit last argument.
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.common.io.BaseEncoding;
-import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
*/
private final SchemaContext schemaContext;
- /**
- * Map<moduleName, Map<moduleDate, Map<typeName, type>>>
- */
private final Map<String, Map<Optional<Revision>, Map<String, Type>>> genTypeDefsContextMap = new HashMap<>();
/**
/**
* Creates new instance of class <code>TypeProviderImpl</code>.
*
- * @param schemaContext
- * contains the schema data red from YANG files
- * @param renames
- * @throws IllegalArgumentException
- * if <code>schemaContext</code> equal null.
+ * @param schemaContext contains the schema data red from YANG files
+ * @param renames renaming table
+ * @throws IllegalArgumentException if <code>schemaContext</code> equal null.
*/
AbstractTypeProvider(final SchemaContext schemaContext, final Map<SchemaNode, JavaTypeName> renames) {
Preconditions.checkArgument(schemaContext != null, "Schema Context cannot be null!");
-
this.schemaContext = schemaContext;
this.renames = requireNonNull(renames);
resolveTypeDefsFromContext();
}
/**
- * Puts <code>refType</code> to map with key <code>refTypePath</code>
+ * Puts <code>refType</code> to map with key <code>refTypePath</code>.
*
- * @param refTypePath
- * schema path used as the map key
- * @param refType
- * type which represents the map value
+ * @param refTypePath schema path used as the map key
+ * @param refType type which represents the map value
* @throws IllegalArgumentException
* <ul>
* <li>if <code>refTypePath</code> equal null</li>
}
/**
- * Converts schema definition type <code>typeDefinition</code> to JAVA
- * <code>Type</code>
+ * Converts schema definition type <code>typeDefinition</code> to JAVA <code>Type</code>.
*
- * @param typeDefinition
- * type definition which is converted to JAVA type
+ * @param typeDefinition type definition which is converted to JAVA type
* @throws IllegalArgumentException
* <ul>
* <li>if <code>typeDefinition</code> equal null</li>
*/
@Override
public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> typeDefinition, final SchemaNode parentNode,
- final Restrictions r) {
+ final Restrictions restrictions) {
Preconditions.checkArgument(typeDefinition != null, "Type Definition cannot be NULL!");
Preconditions.checkArgument(typeDefinition.getQName() != null,
"Type Definition cannot have non specified QName (QName cannot be NULL!)");
// a base type which holds these constraints.
if (typeDefinition instanceof DecimalTypeDefinition) {
final Type ret = BaseYangTypes.BASE_YANG_TYPES_PROVIDER.javaTypeForSchemaDefinitionType(typeDefinition,
- parentNode, r);
+ parentNode, restrictions);
if (ret != null) {
return ret;
}
}
Type returnType = javaTypeForExtendedType(typeDefinition);
- if (r != null && returnType instanceof GeneratedTransferObject) {
+ if (restrictions != null && returnType instanceof GeneratedTransferObject) {
final GeneratedTransferObject gto = (GeneratedTransferObject) returnType;
final Module module = findParentModule(schemaContext, parentNode);
final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
final String genTOName = BindingMapping.getClassName(typedefName);
final String name = packageName + "." + genTOName;
if (!returnType.getFullyQualifiedName().equals(name)) {
- returnType = shadedTOWithRestrictions(gto, r);
+ returnType = shadedTOWithRestrictions(gto, restrictions);
}
}
return returnType;
}
- private GeneratedTransferObject shadedTOWithRestrictions(final GeneratedTransferObject gto, final Restrictions r) {
+ private GeneratedTransferObject shadedTOWithRestrictions(final GeneratedTransferObject gto,
+ final Restrictions restrictions) {
final GeneratedTOBuilder gtob = newGeneratedTOBuilder(gto.getIdentifier());
final GeneratedTransferObject parent = gto.getSuperType();
if (parent != null) {
gtob.setExtendsType(parent);
}
- gtob.setRestrictions(r);
+ gtob.setRestrictions(restrictions);
for (GeneratedProperty gp : gto.getProperties()) {
final GeneratedPropertyBuilder gpb = gtob.addProperty(gp.getName());
gpb.setValue(gp.getValue());
}
/**
- * Returns JAVA <code>Type</code> for instances of the type
- * <code>LeafrefTypeDefinition</code> or
+ * Returns JAVA <code>Type</code> for instances of the type <code>LeafrefTypeDefinition</code> or
* <code>IdentityrefTypeDefinition</code>.
*
- * @param typeDefinition
- * type definition which is converted to JAVA <code>Type</code>
+ * @param typeDefinition type definition which is converted to JAVA <code>Type</code>
* @return JAVA <code>Type</code> instance for <code>typeDefinition</code>
*/
private Type javaTypeForLeafrefOrIdentityRef(final TypeDefinition<?> typeDefinition, final SchemaNode parentNode) {
}
/**
- * Returns JAVA <code>Type</code> for instances of the type
- * <code>ExtendedType</code>.
+ * Returns JAVA <code>Type</code> for instances of the type <code>ExtendedType</code>.
*
- * @param typeDefinition
- * type definition which is converted to JAVA <code>Type</code>
+ * @param typeDefinition type definition which is converted to JAVA <code>Type</code>
* @return JAVA <code>Type</code> instance for <code>typeDefinition</code>
*/
private Type javaTypeForExtendedType(final TypeDefinition<?> typeDefinition) {
}
/**
- * Seeks for identity reference <code>idref</code> the JAVA
- * <code>type</code>.<br />
- * <br />
+ * Seeks for identity reference <code>idref</code> the JAVA <code>type</code>.
*
+ * <p>
* <i>Example:<br />
* If identy which is referenced via <code>idref</code> has name <b>Idn</b>
* then returning type is <b>{@code Class<? extends Idn>}</b></i>
*
- * @param idref
- * identityref type definition for which JAVA <code>Type</code>
- * is sought
- * @return JAVA <code>Type</code> of the identity which is referenced through
- * <code>idref</code>
+ * @param idref identityref type definition for which JAVA <code>Type</code> is sought
+ * @return JAVA <code>Type</code> of the identity which is referenced through <code>idref</code>
*/
private Type provideTypeForIdentityref(final IdentityrefTypeDefinition idref) {
final Collection<IdentitySchemaNode> identities = idref.getIdentities();
Preconditions.checkArgument(identity != null, "Target identity '" + baseIdQName + "' do not exists");
final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
- final JavaTypeName identifier = JavaTypeName.create(BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
- identity.getPath()), BindingMapping.getClassName(identity.getQName()));
+ final JavaTypeName identifier = JavaTypeName.create(BindingGeneratorUtil.packageNameForGeneratedType(
+ basePackageName, identity.getPath()), BindingMapping.getClassName(identity.getQName()));
return Types.classType(Types.wildcardTypeFor(identifier));
}
* <li>if name of <code>typeDefinition</code></li>
* </ul>
*/
- public Type generatedTypeForExtendedDefinitionType(final TypeDefinition<?> typeDefinition, final SchemaNode parentNode) {
+ public Type generatedTypeForExtendedDefinitionType(final TypeDefinition<?> typeDefinition,
+ final SchemaNode parentNode) {
Preconditions.checkArgument(typeDefinition != null, "Type Definition cannot be NULL!");
if (typeDefinition.getQName() == null) {
- throw new IllegalArgumentException(
- "Type Definition cannot have non specified QName (QName cannot be NULL!)");
+ throw new IllegalArgumentException("Type Definition cannot have unspecified QName (QName cannot be NULL!)");
}
Preconditions.checkArgument(typeDefinition.getQName().getLocalName() != null,
"Type Definitions Local Name cannot be NULL!");
}
/**
- * Converts <code>leafrefType</code> to JAVA <code>Type</code>.
- *
- * The path of <code>leafrefType</code> is followed to find referenced node
- * and its <code>Type</code> is returned.
+ * Converts <code>leafrefType</code> to JAVA <code>Type</code>. The path of <code>leafrefType</code> is followed
+ * to find referenced node and its <code>Type</code> is returned.
*
- * @param leafrefType
- * leafref type definition for which is the type sought
- * @return JAVA <code>Type</code> of data schema node which is referenced in
- * <code>leafrefType</code>
+ * @param leafrefType leafref type definition for which is the type sought
+ * @return JAVA <code>Type</code> of data schema node which is referenced in <code>leafrefType</code>
* @throws IllegalArgumentException
* <ul>
* <li>if <code>leafrefType</code> equal null</li>
*
*/
public Type provideTypeForLeafref(final LeafrefTypeDefinition leafrefType, final SchemaNode parentNode) {
- Type returnType = null;
Preconditions.checkArgument(leafrefType != null, "Leafref Type Definition reference cannot be NULL!");
-
Preconditions.checkArgument(leafrefType.getPathStatement() != null,
"The Path Statement for Leafref Type Definition cannot be NULL!");
final RevisionAwareXPath xpath = leafrefType.getPathStatement();
final String strXPath = xpath.toString();
+ Type returnType = null;
if (strXPath != null) {
if (strXPath.indexOf('[') == -1) {
}
/**
- * Checks if <code>dataNode</code> is <code>LeafSchemaNode</code> and if it
- * so then checks if it is of type <code>EnumTypeDefinition</code>.
+ * Checks if <code>dataNode</code> is <code>LeafSchemaNode</code> and if it so then checks if it is of type
+ * <code>EnumTypeDefinition</code>.
*
- * @param dataNode
- * data schema node for which is checked if it is leaf and if it
- * is of enum type
+ * @param dataNode data schema node for which is checked if it is leaf and if it is of enum type
* @return boolean value
* <ul>
* <li>true - if <code>dataNode</code> is leaf of type enumeration</li>
}
/**
- * Checks if <code>dataNode</code> is <code>LeafListSchemaNode</code> and if
- * it so then checks if it is of type <code>EnumTypeDefinition</code>.
+ * Checks if <code>dataNode</code> is <code>LeafListSchemaNode</code> and if it so then checks if it is of type
+ * <code>EnumTypeDefinition</code>.
*
- * @param dataNode
- * data schema node for which is checked if it is leaflist and if
- * it is of enum type
+ * @param dataNode data schema node for which is checked if it is leaflist and if it is of enum type
* @return boolean value
* <ul>
* <li>true - if <code>dataNode</code> is leaflist of type
}
/**
- * Converts <code>enumTypeDef</code> to
- * {@link Enumeration
- * enumeration}.
+ * Converts <code>enumTypeDef</code> to {@link Enumeration enumeration}.
*
- * @param enumTypeDef
- * enumeration type definition which is converted to enumeration
- * @param enumName
- * string with name which is used as the enumeration name
- * @return enumeration type which is built with data (name, enum values)
- * from <code>enumTypeDef</code>
+ * @param enumTypeDef enumeration type definition which is converted to enumeration
+ * @param enumName string with name which is used as the enumeration name
+ * @return enumeration type which is built with data (name, enum values) from <code>enumTypeDef</code>
* @throws IllegalArgumentException
* <ul>
* <li>if <code>enumTypeDef</code> equals null</li>
}
/**
- * Adds enumeration to <code>typeBuilder</code>. The enumeration data are
- * taken from <code>enumTypeDef</code>.
+ * Adds enumeration to <code>typeBuilder</code>. The enumeration data are taken from <code>enumTypeDef</code>.
*
- * @param enumTypeDef
- * enumeration type definition is source of enumeration data for
- * <code>typeBuilder</code>
- * @param enumName
- * string with the name of enumeration
- * @param typeBuilder
- * generated type builder to which is enumeration added
- * @return enumeration type which contains enumeration data form
- * <code>enumTypeDef</code>
+ * @param enumTypeDef enumeration type definition is source of enumeration data for <code>typeBuilder</code>
+ * @param enumName string with the name of enumeration
+ * @param typeBuilder generated type builder to which is enumeration added
+ * @return enumeration type which contains enumeration data form <code>enumTypeDef</code>
* @throws IllegalArgumentException
* <ul>
* <li>if <code>enumTypeDef</code> equals null</li>
abstract void addCodegenInformation(GeneratedTypeBuilderBase<?> genTOBuilder, TypeDefinition<?> typeDef);
/**
- * Converts the pattern constraints from <code>typedef</code> to the list of
- * the strings which represents these constraints.
+ * Converts the pattern constraints from <code>typedef</code> to the list of the strings which represents these
+ * constraints.
*
- * @param typedef
- * extended type in which are the pattern constraints sought
+ * @param typedef extended type in which are the pattern constraints sought
* @return list of strings which represents the constraint patterns
- * @throws IllegalArgumentException
- * if <code>typedef</code> equals null
+ * @throws IllegalArgumentException if <code>typedef</code> equals null
*
*/
private Map<String, String> resolveRegExpressionsFromTypedef(final TypeDefinition<?> typedef) {
/**
* Converts <code>dataNode</code> to JAVA <code>Type</code>.
*
- * @param dataNode
- * contains information about YANG type
+ * @param dataNode contains information about YANG type
* @return JAVA <code>Type</code> representation of <code>dataNode</code>
*/
private Type resolveTypeFromDataSchemaNode(final SchemaNode dataNode) {
}
/**
- * Passes through all modules and through all its type definitions and
- * convert it to generated types.
+ * Passes through all modules and through all its type definitions and convert it to generated types.
*
- * The modules are firstly sorted by mutual dependencies. The modules are
- * sequentially passed. All type definitions of a module are at the
- * beginning sorted so that type definition with less amount of references
- * to other type definition are processed first.<br />
+ * <p>
+ * The modules are first sorted by mutual dependencies. The modules are sequentially passed. All type definitions
+ * of a module are at the beginning sorted so that type definition with less amount of references to other type
+ * definition are processed first.<br>
* For each module is created mapping record in the map
* {@link AbstractTypeProvider#genTypeDefsContextMap genTypeDefsContextMap}
- * which map current module name to the map which maps type names to
- * returned types (generated types).
- *
+ * which map current module name to the map which maps type names to returned types (generated types).
*/
private void resolveTypeDefsFromContext() {
final Set<Module> modules = schemaContext.getModules();
}
/**
+ * Create Type for specified type definition.
*
- * @param basePackageName
- * string with name of package to which the module belongs
- * @param module
- * string with the name of the module for to which the
- * <code>typedef</code> belongs
- * @param typedef
- * type definition of the node for which should be created JAVA <code>Type</code> (usually generated TO)
+ * @param basePackageName string with name of package to which the module belongs
+ * @param module string with the name of the module for to which the <code>typedef</code> belongs
+ * @param typedef type definition of the node for which should be created JAVA <code>Type</code>
+ * (usually generated TO)
* @return JAVA <code>Type</code> representation of <code>typedef</code> or
* <code>null</code> value if <code>basePackageName</code> or
* <code>modulName</code> or <code>typedef</code> or Q name of
method.setStatic(true);
Set<Type> types = additionalTypes.get(module);
if (types == null) {
- types = Sets.<Type> newHashSet(unionBuilder.build());
+ types = Sets.newHashSet(unionBuilder.build());
additionalTypes.put(module, types);
} else {
types.add(unionBuilder.build());
/**
* Wraps base YANG type to generated TO.
*
- * @param basePackageName
- * string with name of package to which the module belongs
- * @param typedef
- * type definition which is converted to the TO
- * @param javaType
- * JAVA <code>Type</code> to which is <code>typedef</code> mapped
+ * @param basePackageName string with name of package to which the module belongs
+ * @param typedef type definition which is converted to the TO
+ * @param javaType JAVA <code>Type</code> to which is <code>typedef</code> mapped
* @return generated transfer object which represent<code>javaType</code>
*/
private GeneratedTransferObject wrapJavaTypeIntoTO(final String basePackageName, final TypeDefinition<?> typedef,
}
/**
- * Converts <code>typedef</code> to generated TO with
- * <code>typeDefName</code>. Every union type from <code>typedef</code> is
- * added to generated TO builder as property.
+ * Converts <code>typedef</code> to generated TO with <code>typeDefName</code>. Every union type from
+ * <code>typedef</code> is added to generated TO builder as property.
*
* @param typeName new type identifier
- * @param typedef
- * type definition which should be of type
- * <code>UnionTypeDefinition</code>
+ * @param typedef type definition which should be of type <code>UnionTypeDefinition</code>
* @return generated TO builder which represents <code>typedef</code>
* @throws NullPointerException
* <ul>
/**
* Wraps code which handles the case when union subtype is also of the type <code>UnionType</code>.
*
+ * <p>
* In this case the new generated TO is created for union subtype (recursive call of method
* {@link #provideGeneratedTOBuildersForUnionTypeDef(String, UnionTypeDefinition, String, SchemaNode)}
* provideGeneratedTOBuilderForUnionTypeDef} and in parent TO builder <code>parentUnionGenTOBuilder</code> is
* created property which type is equal to new generated TO.
*
- * @param parentUnionGenTOBuilder
- * generated TO builder to which is the property with the child
- * union subtype added
- * @param basePackageName
- * string with the name of the module package
- * @param unionSubtype
- * type definition which represents union subtype
- * @return list of generated TO builders. The number of the builders can be
- * bigger one due to recursive call of
+ * @param parentUnionGenTOBuilder generated TO builder to which is the property with the child union subtype added
+ * @param basePackageName string with the name of the module package
+ * @param unionSubtype type definition which represents union subtype
+ * @return list of generated TO builders. The number of the builders can be bigger one due to recursive call of
* <code>provideGeneratedTOBuildersForUnionTypeDef</code> method.
*/
private List<GeneratedTOBuilder> resolveUnionSubtypeAsUnion(final GeneratedTOBuilder parentUnionGenTOBuilder,
}
/**
- * Wraps code which handle case when union subtype is of the type
- * <code>ExtendedType</code>.
- *
- * If TO for this type already exists it is used for the creation of the
- * property in <code>parentUnionGenTOBuilder</code>. In other case the base
- * type is used for the property creation.
- *
- * @param parentUnionGenTOBuilder
- * generated TO builder in which new property is created
- * @param unionSubtype
- * type definition of the <code>ExtendedType</code> type which
- * represents union subtype
- * @param expressions
- * list of strings with the regular expressions
- * @param parentNode
- * parent Schema Node for Extended Subtype
+ * Wraps code which handle case when union subtype is of the type <code>ExtendedType</code>. If TO for this type
+ * already exists it is used for the creation of the property in <code>parentUnionGenTOBuilder</code>. Otherwise
+ * the base type is used for the property creation.
*
+ * @param parentUnionGenTOBuilder generated TO builder in which new property is created
+ * @param unionSubtype type definition of the <code>ExtendedType</code> type which represents union subtype
+ * @param expressions list of strings with the regular expressions
+ * @param parentNode parent Schema Node for Extended Subtype
*/
private void resolveExtendedSubtypeAsUnion(final GeneratedTOBuilder parentUnionGenTOBuilder,
final TypeDefinition<?> unionSubtype, final Map<String, String> expressions, final SchemaNode parentNode) {
}
/**
- * Searches for generated TO for <code>searchedTypeDef</code> type
- * definition in {@link #genTypeDefsContextMap genTypeDefsContextMap}
+ * Searches for generated TO for <code>searchedTypeDef</code> type definition
+ * in {@link #genTypeDefsContextMap genTypeDefsContextMap}.
*
- * @param searchedTypeName
- * string with name of <code>searchedTypeDef</code>
- * @return generated TO for <code>searchedTypeDef</code> or
- * <code>null</code> it it doesn't exist
+ * @param searchedTypeName string with name of <code>searchedTypeDef</code>
+ * @return generated TO for <code>searchedTypeDef</code> or <code>null</code> it it doesn't exist
*/
private Type findGenTO(final String searchedTypeName, final SchemaNode parentNode) {
final Module typeModule = findParentModule(schemaContext, parentNode);
if (typeModule != null && typeModule.getName() != null) {
- final Map<Optional<Revision>, Map<String, Type>> modulesByDate = genTypeDefsContextMap.get(typeModule.getName());
+ final Map<Optional<Revision>, Map<String, Type>> modulesByDate = genTypeDefsContextMap.get(
+ typeModule.getName());
final Map<String, Type> genTOs = modulesByDate.get(typeModule.getRevision());
if (genTOs != null) {
return genTOs.get(searchedTypeName);
}
/**
- * Stores generated TO created from <code>genTOBuilder</code> for
- * <code>newTypeDef</code> to {@link #genTypeDefsContextMap
- * genTypeDefsContextMap} if the module for <code>newTypeDef</code> exists
+ * Stores generated TO created from <code>genTOBuilder</code> for <code>newTypeDef</code>
+ * to {@link #genTypeDefsContextMap genTypeDefsContextMap} if the module for <code>newTypeDef</code> exists.
*
- * @param newTypeDef
- * type definition for which is <code>genTOBuilder</code> created
- * @param genTOBuilder
- * generated TO builder which is converted to generated TO and
- * stored
+ * @param newTypeDef type definition for which is <code>genTOBuilder</code> created
+ * @param genTOBuilder generated TO builder which is converted to generated TO and stored
*/
- private void storeGenTO(final TypeDefinition<?> newTypeDef, final GeneratedTOBuilder genTOBuilder, final SchemaNode parentNode) {
+ private void storeGenTO(final TypeDefinition<?> newTypeDef, final GeneratedTOBuilder genTOBuilder,
+ final SchemaNode parentNode) {
if (!(newTypeDef instanceof UnionTypeDefinition)) {
final Module parentModule = findParentModule(schemaContext, parentNode);
if (parentModule != null && parentModule.getName() != null) {
- final Map<Optional<Revision>, Map<String, Type>> modulesByDate = genTypeDefsContextMap.get(parentModule.getName());
+ final Map<Optional<Revision>, Map<String, Type>> modulesByDate = genTypeDefsContextMap.get(
+ parentModule.getName());
final Map<String, Type> genTOsMap = modulesByDate.get(parentModule.getRevision());
genTOsMap.put(newTypeDef.getQName().getLocalName(), genTOBuilder.build());
}
}
/**
- * Adds a new property with the name <code>propertyName</code> and with type
- * <code>type</code> to <code>unonGenTransObject</code>.
+ * Adds a new property with the name <code>propertyName</code> and with type <code>type</code>
+ * to <code>unonGenTransObject</code>.
*
- * @param unionGenTransObject
- * generated TO to which should be property added
- * @param type
- * JAVA <code>type</code> of the property which should be added
- * to <code>unionGentransObject</code>
- * @param propertyName
- * string with name of property which should be added to
- * <code>unionGentransObject</code>
+ * @param unionGenTransObject generated TO to which should be property added
+ * @param type JAVA <code>type</code> of the property which should be added to <code>unionGentransObject</code>
+ * @param propertyName string with name of property which should be added to <code>unionGentransObject</code>
*/
- private static void updateUnionTypeAsProperty(final GeneratedTOBuilder unionGenTransObject, final Type type, final String propertyName) {
+ private static void updateUnionTypeAsProperty(final GeneratedTOBuilder unionGenTransObject, final Type type,
+ final String propertyName) {
if (unionGenTransObject != null && type != null && !unionGenTransObject.containsProperty(propertyName)) {
final GeneratedPropertyBuilder propBuilder = unionGenTransObject
.addProperty(BindingMapping.getPropertyName(propertyName));
/**
* Converts <code>typedef</code> to the generated TO builder.
*
- * @param basePackageName
- * string with name of package to which the module belongs
- * @param typedef
- * type definition from which is the generated TO builder created
- * @return generated TO builder which contains data from
- * <code>typedef</code> and <code>basePackageName</code>
+ * @param basePackageName string with name of package to which the module belongs
+ * @param typedef type definition from which is the generated TO builder created
+ * @return generated TO builder which contains data from <code>typedef</code> and <code>basePackageName</code>
*/
private GeneratedTOBuilder typedefToTransferObject(final String basePackageName,
final TypeDefinition<?> typedef, final String moduleName) {
}
/**
- * Converts <code>typeDef</code> which should be of the type
- * <code>BitsTypeDefinition</code> to <code>GeneratedTOBuilder</code>.
- *
- * All the bits of the typeDef are added to returning generated TO as
+ * Converts <code>typeDef</code> which should be of the type <code>BitsTypeDefinition</code>
+ * to <code>GeneratedTOBuilder</code>. All the bits of the typeDef are added to returning generated TO as
* properties.
*
* @param typeName new type identifier
- * @param typeDef
- * type definition from which is the generated TO builder created
+ * @param typeDef type definition from which is the generated TO builder created
* @return generated TO builder which represents <code>typeDef</code>
* @throws IllegalArgumentException
* <ul>
}
/**
+ * Adds to the <code>genTOBuilder</code> the constant which contains regular expressions from
+ * the <code>regularExpressions</code>.
*
- * Adds to the <code>genTOBuilder</code> the constant which contains regular
- * expressions from the <code>regularExpressions</code>
- *
- * @param genTOBuilder
- * generated TO builder to which are
- * <code>regular expressions</code> added
- * @param expressions
- * list of string which represent regular expressions
+ * @param genTOBuilder generated TO builder to which are <code>regular expressions</code> added
+ * @param expressions list of string which represent regular expressions
*/
private static void addStringRegExAsConstant(final GeneratedTOBuilder genTOBuilder,
final Map<String, String> expressions) {
}
/**
- * Creates generated TO with data about inner extended type
- * <code>innerExtendedType</code>, about the package name
- * <code>typedefName</code> and about the generated TO name
- * <code>typedefName</code>.
+ * Creates generated TO with data about inner extended type <code>innerExtendedType</code>, about the package name
+ * <code>typedefName</code> and about the generated TO name <code>typedefName</code>.
*
- * It is supposed that <code>innerExtendedType</code> is already present in
- * {@link AbstractTypeProvider#genTypeDefsContextMap genTypeDefsContextMap} to
- * be possible set it as extended type for the returning generated TO.
+ * <p>
+ * It is assumed that <code>innerExtendedType</code> is already present in
+ * {@link AbstractTypeProvider#genTypeDefsContextMap genTypeDefsContextMap} to be possible set it as extended type
+ * for the returning generated TO.
*
- * @param typedef
- * Type Definition
- * @param innerExtendedType
- * extended type which is part of some other extended type
- * @param basePackageName
- * string with the package name of the module
- * @param moduleName
- * Module Name
- * @return generated TO which extends generated TO for
- * <code>innerExtendedType</code>
+ * @param typedef Type Definition
+ * @param innerExtendedType extended type which is part of some other extended type
+ * @param basePackageName string with the package name of the module
+ * @param moduleName Module Name
+ * @return generated TO which extends generated TO for <code>innerExtendedType</code>
* @throws IllegalArgumentException
* <ul>
* <li>if <code>extendedType</code> equals null</li>
}
/**
- * Add {@link Serializable} to implemented interfaces of this TO. Also
- * compute and add serialVersionUID property.
+ * Add {@link java.io.Serializable} to implemented interfaces of this TO. Also compute and add serialVersionUID
+ * property.
*
- * @param gto
- * transfer object which needs to be serializable
+ * @param gto transfer object which needs to be made serializable
*/
private static void makeSerializable(final GeneratedTOBuilder gto) {
gto.addImplementsType(Types.serializableType());
}
/**
- * Finds out for each type definition how many immersion (depth) is
- * necessary to get to the base type. Every type definition is inserted to
- * the map which key is depth and value is list of type definitions with
- * equal depth. In next step are lists from this map concatenated to one
- * list in ascending order according to their depth. All type definitions
- * are in the list behind all type definitions on which depends.
+ * Finds out for each type definition how many immersion (depth) is necessary to get to the base type. Every type
+ * definition is inserted to the map which key is depth and value is list of type definitions with equal depth.
+ * In next step are lists from this map concatenated to one list in ascending order according to their depth. All
+ * type definitions are in the list behind all type definitions on which depends.
*
- * @param unsortedTypeDefinitions
- * list of type definitions which should be sorted by depth
- * @return list of type definitions sorted according their each other
- * dependencies (type definitions which are depend on other type
- * definitions are in list behind them).
+ * @param unsortedTypeDefinitions list of type definitions which should be sorted by depth
+ * @return list of type definitions sorted according their each other dependencies (type definitions which are
+ * dependent on other type definitions are in list behind them).
*/
private static List<TypeDefinition<?>> sortTypeDefinitionAccordingDepth(
final Collection<TypeDefinition<?>> unsortedTypeDefinitions) {
}
/**
- * Returns how many immersion is necessary to get from the type definition
- * to the base type.
+ * Returns how many immersion is necessary to get from the type definition to the base type.
*
- * @param typeDefinition
- * type definition for which is depth sought.
- * @return number of immersions which are necessary to get from the type
- * definition to the base type
+ * @param typeDefinition type definition for which is depth sought.
+ * @return number of immersions which are necessary to get from the type definition to the base type
*/
private static int getTypeDefinitionDepth(final TypeDefinition<?> typeDefinition) {
// FIXME: rewrite this in a non-recursive manner
className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
} else {
final String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule());
- final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, type.getPath());
+ final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
+ type.getPath());
parentName = BindingMapping.getClassName(parent.getName());
className = packageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
}
if (type.getBaseType() != null) {
final Module m = getParentModule(type);
final String basePackageName = BindingMapping.getRootPackageName(m.getQNameModule());
- final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, type.getPath());
+ final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
+ type.getPath());
className = packageName + "." + BindingMapping.getClassName(typeQName);
} else {
final Module parentModule = getParentModule(node);
final String basePackageName = BindingMapping.getRootPackageName(parentModule.getQNameModule());
- final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, node.getPath());
+ final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
+ node.getPath());
className = packageName + "." + BindingMapping.getClassName(node.getQName());
}
result = className + "." + newDefVal;
&& !(base instanceof EnumTypeDefinition) && !(base instanceof UnionTypeDefinition)) {
final Module m = getParentModule(type);
final String basePackageName = BindingMapping.getRootPackageName(m.getQNameModule());
- final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, type.getPath());
+ final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
+ type.getPath());
final String className = packageName + "." + BindingMapping.getClassName(typeQName);
sb.insert(0, "new " + className + "(");
sb.insert(sb.length(), ')');
private static final Comparator<Bit> BIT_NAME_COMPARATOR = Comparator.comparing(Bit::getName);
- private static String bitsToDef(final BitsTypeDefinition type, final String className, final String defaultValue, final boolean isExt) {
+ private static String bitsToDef(final BitsTypeDefinition type, final String className, final String defaultValue,
+ final boolean isExt) {
final List<Bit> bits = new ArrayList<>(type.getBits());
bits.sort(BIT_NAME_COMPARATOR);
final StringBuilder sb = new StringBuilder();
return schemaContext.findModule(qname.getModule()).orElse(null);
}
- private String leafrefToDef(final LeafSchemaNode parentNode, final LeafrefTypeDefinition leafrefType, final String defaultValue) {
+ private String leafrefToDef(final LeafSchemaNode parentNode, final LeafrefTypeDefinition leafrefType,
+ final String defaultValue) {
Preconditions.checkArgument(leafrefType != null, "Leafref Type Definition reference cannot be NULL!");
Preconditions.checkArgument(leafrefType.getPathStatement() != null,
"The Path Statement for Leafref Type Definition cannot be NULL!");
parentName = BindingMapping.getClassName(parent.getName()) + "Data";
className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
} else {
- final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, UNION_PATH);
+ final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName,
+ UNION_PATH);
className = packageName + "." + BindingMapping.getClassName(node.getQName());
}
}
public final class BaseYangTypes {
/**
- * mapping of basic built-in YANG types (keys) to JAVA
- * {@link org.opendaylight.mdsal.binding.model.api.Type Type}. This
- * map is filled with mapping data in static initialization block
+ * mapping of basic built-in YANG types (keys) to JAVA {@link org.opendaylight.mdsal.binding.model.api.Type Type}.
+ * This map is filled with mapping data in static initialization block.
*/
private static final Map<String, Type> TYPE_MAP;
/**
- * <code>Type</code> representation of <code>boolean</code> YANG type
+ * <code>Type</code> representation of <code>boolean</code> YANG type.
*/
public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class);
/**
- * <code>Type</code> representation of <code>empty</code> YANG type
+ * <code>Type</code> representation of <code>empty</code> YANG type.
*/
public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class);
public static final Type ENUM_TYPE = Types.typeForClass(Enum.class);
/**
- * <code>Type</code> representation of <code>int8</code> YANG type
+ * <code>Type</code> representation of <code>int8</code> YANG type.
*/
public static final Type INT8_TYPE = Types.typeForClass(Byte.class);
/**
- * <code>Type</code> representation of <code>int16</code> YANG type
+ * <code>Type</code> representation of <code>int16</code> YANG type.
*/
public static final Type INT16_TYPE = Types.typeForClass(Short.class);
/**
- * <code>Type</code> representation of <code>int32</code> YANG type
+ * <code>Type</code> representation of <code>int32</code> YANG type.
*/
public static final Type INT32_TYPE = Types.typeForClass(Integer.class);
/**
- * <code>Type</code> representation of <code>int64</code> YANG type
+ * <code>Type</code> representation of <code>int64</code> YANG type.
*/
public static final Type INT64_TYPE = Types.typeForClass(Long.class);
/**
- * <code>Type</code> representation of <code>string</code> YANG type
+ * <code>Type</code> representation of <code>string</code> YANG type.
*/
public static final Type STRING_TYPE = Types.typeForClass(String.class);
/**
- * <code>Type</code> representation of <code>decimal64</code> YANG type
+ * <code>Type</code> representation of <code>decimal64</code> YANG type.
*/
public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class);
/**
- * <code>Type</code> representation of <code>uint8</code> YANG type
+ * <code>Type</code> representation of <code>uint8</code> YANG type.
*/
- public static final Type UINT8_TYPE = Types.typeForClass(Short.class, singleRangeRestrictions((short)0, (short)255));
+ public static final Type UINT8_TYPE = Types.typeForClass(Short.class, singleRangeRestrictions((short)0,
+ (short)255));
/**
- * <code>Type</code> representation of <code>uint16</code> YANG type
+ * <code>Type</code> representation of <code>uint16</code> YANG type.
*/
public static final Type UINT16_TYPE = Types.typeForClass(Integer.class, singleRangeRestrictions(0, 65535));
/**
- * <code>Type</code> representation of <code>uint32</code> YANG type
+ * <code>Type</code> representation of <code>uint32</code> YANG type.
*/
public static final Type UINT32_TYPE = Types.typeForClass(Long.class, singleRangeRestrictions(0L, 4294967295L));
/**
- * <code>Type</code> representation of <code>uint64</code> YANG type
+ * <code>Type</code> representation of <code>uint64</code> YANG type.
*/
public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class,
singleRangeRestrictions(BigInteger.ZERO, new BigInteger("18446744073709551615")));
public static final Type UNION_TYPE = new UnionType();
/**
- * <code>Type</code> representation of <code>binary</code> YANG type
+ * <code>Type</code> representation of <code>binary</code> YANG type.
*/
public static final Type BINARY_TYPE = Types.typeForClass(byte[].class);
final Restrictions restrictions) {
String typeName = type.getQName().getLocalName();
switch (typeName) {
- case "binary":
- return restrictions == null ? Types.BYTE_ARRAY : Types.typeForClass(byte[].class, restrictions);
- case "decimal64":
- return Types.typeForClass(BigDecimal.class, restrictions);
- case "enumeration":
- return Types.typeForClass(Enum.class, restrictions);
- case "int8":
- return Types.typeForClass(Byte.class, restrictions);
- case "int16":
- return Types.typeForClass(Short.class, restrictions);
- case "int32":
- return Types.typeForClass(Integer.class, restrictions);
- case "int64":
- return Types.typeForClass(Long.class, restrictions);
- case "string":
- return Types.typeForClass(String.class, restrictions);
- case "uint8":
- return Types.typeForClass(Short.class, restrictions);
- case "uint16":
- return Types.typeForClass(Integer.class, restrictions);
- case "uint32":
- return Types.typeForClass(Long.class, restrictions);
- case "uint64":
- return Types.typeForClass(BigInteger.class, restrictions);
- case "union" :
- return UNION_TYPE;
- default:
- return javaTypeForSchemaDefinitionType(type, parentNode);
+ case "binary":
+ return restrictions == null ? Types.BYTE_ARRAY : Types.typeForClass(byte[].class, restrictions);
+ case "decimal64":
+ return Types.typeForClass(BigDecimal.class, restrictions);
+ case "enumeration":
+ return Types.typeForClass(Enum.class, restrictions);
+ case "int8":
+ return Types.typeForClass(Byte.class, restrictions);
+ case "int16":
+ return Types.typeForClass(Short.class, restrictions);
+ case "int32":
+ return Types.typeForClass(Integer.class, restrictions);
+ case "int64":
+ return Types.typeForClass(Long.class, restrictions);
+ case "string":
+ return Types.typeForClass(String.class, restrictions);
+ case "uint8":
+ return Types.typeForClass(Short.class, restrictions);
+ case "uint16":
+ return Types.typeForClass(Integer.class, restrictions);
+ case "uint32":
+ return Types.typeForClass(Long.class, restrictions);
+ case "uint64":
+ return Types.typeForClass(BigInteger.class, restrictions);
+ case "union" :
+ return UNION_TYPE;
+ default:
+ return javaTypeForSchemaDefinitionType(type, parentNode);
}
}
* Creates new instance of class <code>TypeProviderImpl</code>.
*
* @param schemaContext contains the schema data read from YANG files
- * @param renames
+ * @param renames renaming table
* @throws IllegalArgumentException if <code>schemaContext</code> is null.
*/
public CodegenTypeProvider(final SchemaContext schemaContext, final Map<SchemaNode, JavaTypeName> renames) {
import org.opendaylight.yangtools.yang.model.api.UsesNode;
public class GroupingDefinitionDependencySort {
-
/**
- * Sorts set <code>groupingDefinitions</code> according to the mutual
- * dependencies.<br>
- *
- * Elements of <code>groupingDefinitions</code> are firstly transformed to
- * {@link TopologicalSort.Node Node} interfaces and then are sorted by
- * {@link TopologicalSort#sort(Set) sort()} method of <code>TopologicalSort</code>.<br>
- * <br>
+ * Sorts set <code>groupingDefinitions</code> according to the mutual dependencies.<br>
+ * Elements of <code>groupingDefinitions</code> are firstly transformed to {@link TopologicalSort.Node Node}
+ * interfaces and then are sorted by {@link TopologicalSort#sort(Set) sort()} method
+ * of <code>TopologicalSort</code>.<br>
*
* <i>Definition of dependency relation:<br>
* The first <code>GroupingDefinition</code> object (in this context)
* {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer#getUses()
* getUses} method) reference to the second one.</i>
*
- * @param groupingDefinitions
- * set of grouping definition which should be sorted according to
- * mutual dependencies
- * @return list of grouping definitiond which are sorted by mutual
- * dependencies
- * @throws IllegalArgumentException
- * if <code>groupingDefinitions</code>
+ * @param groupingDefinitions set of grouping definition which should be sorted according to mutual dependencies
+ * @return list of grouping definitiond which are sorted by mutual dependencies
+ * @throws IllegalArgumentException if <code>groupingDefinitions</code>
*
*/
public List<GroupingDefinition> sort(final Collection<GroupingDefinition> groupingDefinitions) {
if (groupingDefinitions == null) {
- throw new IllegalArgumentException("Set of Type Definitions " + "cannot be NULL!");
+ throw new IllegalArgumentException("Set of Type Definitions cannot be NULL!");
}
final List<GroupingDefinition> resultGroupingDefinitions = new ArrayList<>();
resultGroupingDefinitions.add((GroupingDefinition) nodeWrappedType.getWrappedType());
}
return resultGroupingDefinitions;
-
}
/**
- * Wraps every grouping definition to node type and adds to every node
- * information about dependencies.
- *
- * The map with mapping from schema path (represents grouping definition) to
- * node is created. For every created node (next <i>nodeFrom</i>) is for its
- * wrapped grouping definition passed the set of its <i>uses nodes</i>
- * through. For every uses node is found its wrapping node (next as
- * <i>nodeTo</i>). This dependency relationship between nodeFrom and all
- * found nodesTo is modeled with creating of one edge from nodeFrom to
- * nodeTo.
- *
- *
- * @param groupingDefinitions
- * set of goruping definition which will be wrapped to nodes
+ * Wraps every grouping definition to node type and adds to every node information about dependencies. The map
+ * with mapping from schema path (represents grouping definition) to node is created. For every created node
+ * (next <i>nodeFrom</i>) is for its wrapped grouping definition passed the set of its <i>uses nodes</i> through.
+ * For every uses node is found its wrapping node (next as <i>nodeTo</i>). This dependency relationship between
+ * nodeFrom and all found nodesTo is modeled with creating of one edge from nodeFrom to nodeTo.
*
+ * @param groupingDefinitions set of goruping definition which will be wrapped to nodes
* @return set of nodes where every one contains wrapped grouping definition
*/
private Set<Node> groupingDefinitionsToNodes(final Collection<GroupingDefinition> groupingDefinitions) {
}
/**
- * Returns the set of the uses nodes which are get from uses in
- * <code>container</code>, from uses in groupings inside
- * <code>container</code> and from uses inside child nodes of the
- * <code>container</code>.
+ * Returns the set of the uses nodes which are get from uses in <code>container</code>, from uses in groupings
+ * inside <code>container</code> and from uses inside child nodes of the <code>container</code>.
*
- * @param container
- * data node container which can contain some uses of grouping
+ * @param container data node container which can contain some uses of grouping
* @return set of uses nodes which were find in <code>container</code>.
*/
private Set<UsesNode> getAllUsesNodes(final DataNodeContainer container) {
public final class NodeWrappedType extends NodeImpl {
/**
- * The payload which is saved inside Node
+ * The payload which is saved inside Node.
*/
private final Object wrappedType;
/**
* Create new instance of class <code>NodeWrappedType</code>.
- *
- * @param wrappedType
- * object with payload data
+ *
+ * @param wrappedType object with payload data
*/
- NodeWrappedType(Object wrappedType) {
+ NodeWrappedType(final Object wrappedType) {
this.wrappedType = wrappedType;
}
/**
- * Gets payload from class
- *
+ * Gets payload from class.
+ *
* @return object with <code>wrappedType</code>
*/
Object getWrappedType() {
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
}
- if (!(o instanceof NodeWrappedType)) {
+ if (!(obj instanceof NodeWrappedType)) {
return false;
}
- NodeWrappedType nodeWrappedType = (NodeWrappedType) o;
+ NodeWrappedType nodeWrappedType = (NodeWrappedType) obj;
if (!wrappedType.equals(nodeWrappedType.wrappedType)) {
return false;
}
public String toString() {
return "NodeWrappedType{" + "wrappedType=" + wrappedType + '}';
}
-
}
}
@Test
- public void AugmentationWithRelativeXPathTest() {
+ public void testAugmentationWithRelativeXPath() {
final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels);
GeneratedTransferObject gtTunnelKey = null;
for (final Type type : genTypes) {
- if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
+ if (!type.getPackageName().contains("augment._abstract.topology")) {
+ continue;
+ }
+
+ if (type.getName().equals("InterfaceKey")) {
gtInterfaceKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("Interface")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Interface")) {
gtInterface = (GeneratedType) type;
- } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Tunnel")) {
gtTunnel = (GeneratedType) type;
- } else if (type.getName().equals("TunnelKey")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("TunnelKey")) {
gtTunnelKey = (GeneratedTransferObject) type;
}
}
GeneratedType gtNetworkLink2 = null;
for (final Type type : genTypes) {
- if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
+ if (!type.getPackageName().contains("augment._abstract.topology")) {
+ continue;
+ }
+
+ if (type.getName().equals("InterfaceKey")) {
gtInterfaceKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("Interface")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Interface")) {
gtInterface = (GeneratedType) type;
- } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Tunnel")) {
gtTunnel = (GeneratedType) type;
- } else if (type.getName().equals("TunnelKey")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("TunnelKey")) {
gtTunnelKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("NetworkLink2")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("NetworkLink2")) {
gtNetworkLink2 = (GeneratedType) type;
}
}
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class BinaryTypeTest {
- private final static List<File> yangModels = new ArrayList<>();
- private final static URL yangModelsFolder = AugmentedTypeTest.class
- .getResource("/binary-type-test-models");
+ private static final List<File> YANG_MODELS = new ArrayList<>();
+ private static final URL YANG_MODELS_FOLDER = AugmentedTypeTest.class.getResource("/binary-type-test-models");
@BeforeClass
public static void loadTestResources() throws URISyntaxException {
- final File augFolder = new File(yangModelsFolder.toURI());
+ final File augFolder = new File(YANG_MODELS_FOLDER.toURI());
for (final File fileEntry : augFolder.listFiles()) {
if (fileEntry.isFile()) {
- yangModels.add(fileEntry);
+ YANG_MODELS.add(fileEntry);
}
}
}
@Test
public void binaryTypeTest() {
- final SchemaContext context = YangParserTestUtils.parseYangFiles(yangModels);
+ final SchemaContext context = YangParserTestUtils.parseYangFiles(YANG_MODELS);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
for (Type type : generateTypes) {
switch (type.getName()) {
- case "ChoiceTestData":
- choiceTestData = (GeneratedType) type;
- break;
- case "Myrootcontainer":
- myRootContainer = (GeneratedType) type;
- break;
- case "Mylist":
- myList = (GeneratedType) type;
- break;
- case "Mylist2":
- myList2 = (GeneratedType) type;
- break;
- case "Mycontainer":
- myContainer = (GeneratedType) type;
- break;
- case "Mycontainer2":
- myContainer2 = (GeneratedType) type;
- break;
+ case "ChoiceTestData":
+ choiceTestData = (GeneratedType) type;
+ break;
+ case "Myrootcontainer":
+ myRootContainer = (GeneratedType) type;
+ break;
+ case "Mylist":
+ myList = (GeneratedType) type;
+ break;
+ case "Mylist2":
+ myList2 = (GeneratedType) type;
+ break;
+ case "Mycontainer":
+ myContainer = (GeneratedType) type;
+ break;
+ case "Mycontainer2":
+ myContainer2 = (GeneratedType) type;
+ break;
+ default:
+ // ignore
}
}
List<Type> impl = foo.getImplements();
for (Type type : impl) {
switch (type.getName()) {
- case "ChildOf":
- childOf = type;
- break;
- case "DataObject":
- dataObject = type;
- break;
+ case "ChildOf":
+ childOf = type;
+ break;
+ case "DataObject":
+ dataObject = type;
+ break;
+ default:
+ // ignore
}
}
assertEquals("TypeUnion$1 has incorrect package name.",
"org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion1.getPackageName());
- assertEquals("TypeUnion1 generated TO has incorrect number of properties", 4, typeUnion1.getProperties().size());
+ assertEquals("TypeUnion1 generated TO has incorrect number of properties", 4,
+ typeUnion1.getProperties().size());
containsAttributes(typeUnion1, true, true, true, new NameTypePattern("uint32", "Long"));
containsAttributes(typeUnion1, true, true, true, new NameTypePattern("int8", "Byte"));
assertEquals("TypeUnion$2 has incorrect package name.",
"org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion2.getPackageName());
- assertEquals("TypeUnion2 generated TO has incorrect number of properties", 2, typeUnion2.getProperties().size());
+ assertEquals("TypeUnion2 generated TO has incorrect number of properties", 2,
+ typeUnion2.getProperties().size());
containsAttributes(typeUnion2, true, true, true, new NameTypePattern("string", "String"));
containsAttributes(typeUnion2, true, true, true, new NameTypePattern("uint64", "BigInteger"));
assertFalse("genTypes is empty", genTypes.isEmpty());
// test for file choice-monitoring
- String pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701.netconf.state.datastores.datastore.locks";
+ String pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701."
+ + "netconf.state.datastores.datastore.locks";
GeneratedType genType = null;
checkGeneratedType(genTypes, "LockType", pcgPref); // choice
containsMethods(genType, new NameTypePattern("getStorageFormat", "StorageFormat"));
containsInterface("Augmentation<Datastore>", genType);
- genType = checkGeneratedType(genTypes, "StorageFormat", pcgPref + ".netconf.state.datastores.datastore"); // choice
+ // choice
+ genType = checkGeneratedType(genTypes, "StorageFormat", pcgPref + ".netconf.state.datastores.datastore");
genType = checkGeneratedType(genTypes, "UnknownFiles", pcgPref
+ ".netconf.state.datastores.datastore.storage.format"); // case
containsMethods(genType, new NameTypePattern("getFiles", "List<Files>"));
containsInterface("StorageFormat", genType);
- genType = checkGeneratedType(genTypes, "Xml", pcgPref + ".netconf.state.datastores.datastore.storage.format"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Xml", pcgPref + ".netconf.state.datastores.datastore.storage.format");
containsMethods(genType, new NameTypePattern("getXmlDef", "XmlDef"));
containsInterface("StorageFormat", genType);
- genType = checkGeneratedType(genTypes, "Yang", pcgPref + ".netconf.state.datastores.datastore.storage.format"); // case
+ // case
+ genType = checkGeneratedType(genTypes, "Yang", pcgPref + ".netconf.state.datastores.datastore.storage.format");
containsMethods(genType, new NameTypePattern("getYangFileName", "String"));
containsInterface("StorageFormat", genType);
-
}
}
package org.opendaylight.mdsal.binding.generator.impl;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import java.lang.reflect.Constructor;
public class CodecTypeUtilsTest {
@Test
- public void newIdentifiableItem() throws Exception {
+ public void newIdentifiableItem() {
assertNotNull(CodecTypeUtils.newIdentifiableItem(Identifiable.class, mock(Identifier.class)));
}
- @Test(expected = UnsupportedOperationException.class)
- public void privateConstructTest() throws Throwable {
+ @Test
+ public void privateConstructTest() throws NoSuchMethodException, ReflectiveOperationException {
final Constructor<?> constructor = CodecTypeUtils.class.getDeclaredConstructor();
constructor.setAccessible(true);
try {
constructor.newInstance();
+ fail();
} catch (InvocationTargetException e) {
- throw e.getCause();
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
}
}
}
\ No newline at end of file
} else {
break;
}
- ParameterizedType pType;
+ ParameterizedType paramType;
if (con.getType() instanceof ParameterizedType) {
- pType = (ParameterizedType) con.getType();
+ paramType = (ParameterizedType) con.getType();
} else {
break;
}
Type[] types;
- if (pType.getName().equals("List")) {
+ if (paramType.getName().equals("List")) {
constantRegExListTypeContainer = true;
- types = pType.getActualTypeArguments();
+ types = paramType.getActualTypeArguments();
} else {
break;
}
}
/**
- * Test mainly for the method
- * TypeProviderImpl#provideTypeForIdentityref(IdentityrefTypeDefinition)
- * provideTypeForIdentityref}
+ * Test mainly for the method TypeProviderImpl#provideTypeForIdentityref(IdentityrefTypeDefinition)
+ * provideTypeForIdentityref}.
*/
@Test
public void testIdentityrefYangBuiltInType() {
}
}
}
- assertNotNull("The method 'getLf' wasn't found", typeName);
+ assertNotNull("The method 'getLf' was not found", typeName);
assertEquals("Return type has incorrect name", "Class", typeName);
assertEquals("Incorrect number of type parameters", 1, numOfActualTypes);
assertEquals("Return type has incorrect actual parameter", "SomeIdentity", actualTypeName);
-
}
-
}
import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
import org.opendaylight.mdsal.binding.model.api.Type;
-public class SupportTestUtil {
+public final class SupportTestUtil {
+ private SupportTestUtil() {
+
+ }
public static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
final List<MethodSignature> searchedSignsIn = genType.getMethodDefinitions();
}
}
- public static void containsAttributes(final GeneratedTransferObject genTO, boolean equal, boolean hash,
- boolean toString, final NameTypePattern... searchedSignsWhat) {
+ public static void containsAttributes(final GeneratedTransferObject genTO, final boolean equal, final boolean hash,
+ final boolean toString, final NameTypePattern... searchedSignsWhat) {
List<GeneratedProperty> searchedPropertiesIn = genTO.getProperties();
containsAttributes(searchedPropertiesIn, "", searchedSignsWhat);
if (equal) {
return nameBuilder.toString();
}
- public static void containsInterface(String interfaceNameSearched, GeneratedType genType) {
+ public static void containsInterface(final String interfaceNameSearched, final GeneratedType genType) {
List<Type> caseCImplements = genType.getImplements();
boolean interfaceFound = false;
for (Type caseCImplement : caseCImplements) {
import com.google.common.collect.ImmutableMap;
import java.util.Set;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TypeProviderIntegrationTest {
- private final String PKG = "org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev131008.";
- private static SchemaContext context;
+ private static final String PKG = "org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev131008.";
+ private static SchemaContext CONTEXT;
private AbstractTypeProvider provider;
- private Module m;
+ private Module module;
@BeforeClass
public static void setup() {
- context = YangParserTestUtils.parseYangResources(TypeProviderIntegrationTest.class, "/type-provider/test.yang",
+ CONTEXT = YangParserTestUtils.parseYangResources(TypeProviderIntegrationTest.class, "/type-provider/test.yang",
"/ietf/ietf-inet-types.yang");
- assertNotNull(context);
+ assertNotNull(CONTEXT);
+ }
+
+ @AfterClass
+ public static void teardown() {
+ CONTEXT = null;
}
@Before
public void init() {
- provider = new CodegenTypeProvider(context, ImmutableMap.of());
- m = context.findModule("test", Revision.of("2013-10-08")).get();
+ provider = new CodegenTypeProvider(CONTEXT, ImmutableMap.of());
+ module = CONTEXT.findModule("test", Revision.of("2013-10-08")).get();
}
@Test
public void testGetTypeDefaultConstructionBinary() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-binary");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-binary");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new byte[] {77, 97, 110}", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-binary");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-binary");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBinary(new byte[] {77, 97, 110})", actual);
}
@Test
public void testGetTypeDefaultConstructionBits() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-bits");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-bits");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "TestData.LeafBits(false, false, true)", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-bits");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-bits");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBits(false, false, true)", actual);
}
@Test
public void testGetTypeDefaultConstructionBoolean() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-boolean");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-boolean");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Boolean.TRUE", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-boolean");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-boolean");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBoolean(java.lang.Boolean.TRUE)", actual);
}
@Test
public void testGetTypeDefaultConstructionDecimal() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-decimal64");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-decimal64");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigDecimal(\"3.14\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-decimal64");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-decimal64");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyDecimal64(new java.math.BigDecimal(\"3.14\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionEmpty() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-empty");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-empty");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Boolean.FALSE", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-empty");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-empty");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyEmpty(java.lang.Boolean.FALSE)", actual);
}
@Test
public void testGetTypeDefaultConstructionEnumeration() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-enumeration");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-enumeration");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev131008.LeafEnumeration.Seven", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-enumeration");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-enumeration");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals(PKG + "MyEnumeration.Seven", actual);
}
@Test
public void testGetTypeDefaultConstructionInt8() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int8");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int8");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Byte.valueOf(\"11\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int8");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int8");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt8(java.lang.Byte.valueOf(\"11\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionInt16() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int16");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int16");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Short.valueOf(\"111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int16");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int16");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt16(java.lang.Short.valueOf(\"111\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionInt32() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int32");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int32");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Integer.valueOf(\"1111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int32");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int32");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt32(java.lang.Integer.valueOf(\"1111\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionInt64() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int64");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int64");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Long.valueOf(\"11111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int64");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int64");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt64(java.lang.Long.valueOf(\"11111\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionLeafref1() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-leafref");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-leafref");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigDecimal(\"1.234\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-leafref");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-leafref");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigDecimal(\"1.234\")", actual);
}
@Test
public void testGetTypeDefaultConstructionLeafref2() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-leafref1");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-leafref1");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBinary(new byte[] {77, 97, 110})", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-leafref1");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-leafref1");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBinary(new byte[] {77, 97, 110})", actual);
}
@Test
public void testGetTypeDefaultConstructionString() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-string");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-string");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("\"name\"", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-string");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-string");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyString(\"name\")", actual);
}
@Test
public void testGetTypeDefaultConstructionUint8() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint8");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint8");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Short.valueOf(\"11\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint8");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint8");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyUint8(java.lang.Short.valueOf(\"11\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionUint16() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint16");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint16");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Integer.valueOf(\"111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint16");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint16");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyUint16(java.lang.Integer.valueOf(\"111\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionUint32() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint32");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint32");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Long.valueOf(\"1111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint32");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint32");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyUint32(java.lang.Long.valueOf(\"1111\"))", actual);
}
@Test
public void testGetTypeDefaultConstructionUint64() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint64");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint64");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigInteger(\"11111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint64");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint64");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyUint64(new java.math.BigInteger(\"11111\"))", actual);
}
@Test
public void testGetTypeDefaultConstruction() {
- final QName leafNode = QName.create(m.getQNameModule(), "ip-leaf");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode);
+ final QName leafNode = QName.create(module.getQNameModule(), "ip-leaf");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode);
String actual = provider.getTypeDefaultConstruction(leaf);
- String exp = "new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address(\"0.0.0.1\")";
+ String exp = "new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924."
+ + "Ipv4Address(\"0.0.0.1\")";
assertEquals(exp, actual);
}
@Test
public void testGetTypeDefaultConstructionUnion() {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-union");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-union");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.getDataChildByName(leafNode1);
String actual = provider.getTypeDefaultConstruction(leaf);
String expected = "new " + PKG + "TestData.LeafUnion(\"111\".toCharArray())";
assertEquals(expected, actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-union");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-union");
+ leaf = (LeafSchemaNode) module.getDataChildByName(leafNode2);
actual = provider.getTypeDefaultConstruction(leaf);
expected = "new " + PKG + "MyUnion(\"111\".toCharArray())";
assertEquals(expected, actual);
@Test
public void testGetTypeDefaultConstructionUnionNested() {
- final QName containerNode1 = QName.create(m.getQNameModule(), "c1");
- ContainerSchemaNode c1 = (ContainerSchemaNode) m.getDataChildByName(containerNode1);
- final QName containerNode2 = QName.create(m.getQNameModule(), "c2");
+ final QName containerNode1 = QName.create(module.getQNameModule(), "c1");
+ ContainerSchemaNode c1 = (ContainerSchemaNode) module.getDataChildByName(containerNode1);
+ final QName containerNode2 = QName.create(module.getQNameModule(), "c2");
ContainerSchemaNode c2 = (ContainerSchemaNode) c1.getDataChildByName(containerNode2);
- final QName containerNode3 = QName.create(m.getQNameModule(), "c3");
+ final QName containerNode3 = QName.create(module.getQNameModule(), "c3");
ContainerSchemaNode c3 = (ContainerSchemaNode) c2.getDataChildByName(containerNode3);
- final QName leafNode = QName.create(m.getQNameModule(), "id");
+ final QName leafNode = QName.create(module.getQNameModule(), "id");
LeafSchemaNode leaf = (LeafSchemaNode) c3.getDataChildByName(leafNode);
String actual = provider.getTypeDefaultConstruction(leaf);
@Test
public void testGetParamNameFromType() {
- m = context.findModule("ietf-inet-types", Revision.of("2010-09-24")).get();
- Set<TypeDefinition<?>> types = m.getTypeDefinitions();
+ module = CONTEXT.findModule("ietf-inet-types", Revision.of("2010-09-24")).get();
+ Set<TypeDefinition<?>> types = module.getTypeDefinitions();
TypeDefinition<?> ipv4 = null;
TypeDefinition<?> ipv6 = null;
TypeDefinition<?> ipv4Pref = null;
case "stringRefValue":
assertEquals(Types.STRING, generatedProperty.getReturnType());
break;
+ default:
+ // ignore
}
}
}
}
}
- assertNotNull("Generated type for RPC test input wasn't generated", rpcTestInput);
+ assertNotNull("Generated type for RPC test input was not generated", rpcTestInput);
assertEquals("RpcTestInput interface - incorrect number of occurences", 1, rpcTestInputCounter);
- assertEquals("RpcTestInput isn't in correct package", "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718",
- rpcTestInput.getPackageName());
+ assertEquals("RpcTestInput is not in correct package",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName());
- assertNotNull("Generated type for RPC test output wasn't generated", rpcTestOutput);
+ assertNotNull("Generated type for RPC test output was not generated", rpcTestOutput);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, rpcTestOutputCounter);
- assertEquals("RpcTestOutput isn't in correct package",
+ assertEquals("RpcTestOutput is not in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName());
- assertNotNull("Generated type for grouping-rpc-input-test wasn't generated", groupingRpcInputTest);
+ assertNotNull("Generated type for grouping-rpc-input-test was not generated", groupingRpcInputTest);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcInputTestCounter);
assertEquals("GroupingRpcInputTest isn't in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcInputTest.getPackageName());
- assertNotNull("Generated type for grouping-rpc-output-test wasn't generated", groupingRpcOutputTest);
+ assertNotNull("Generated type for grouping-rpc-output-test was not generated", groupingRpcOutputTest);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcOutputTestCounter);
assertEquals("GroupingRpcOutputTest isn't in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcOutputTest.getPackageName());
containerGroupingRpcInputTest);
assertEquals("ContainerGroupingRpcInputTest interface - incorrect number of occurences", 1,
containerGroupingRpcInputTestCounter);
- assertEquals("ContainerGroupingRpcInputTest isn't in correct package",
+ assertEquals("ContainerGroupingRpcInputTest is not in correct package",
"org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
containerGroupingRpcInputTest.getPackageName());
*/
package org.opendaylight.mdsal.binding.generator.impl;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.junit.Test;
import org.opendaylight.mdsal.binding.model.util.FormattingUtils;
public class YangTextTemplateTest {
-
- @Test(expected = UnsupportedOperationException.class)
- public void privateConstructTest() throws Throwable {
+ @Test
+ public void privateConstructTest() throws ReflectiveOperationException {
final Constructor<FormattingUtils> constructor = FormattingUtils.class.getDeclaredConstructor();
constructor.setAccessible(true);
try {
constructor.newInstance();
+ fail();
} catch (InvocationTargetException e) {
- throw e.getCause();
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
}
}
}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
final TypeDefinition<?> typeDefinition = mock(TypeDefinition.class);
doReturn(Q_NAME).when(typeDefinition).getQName();
doReturn(ImmutableSet.of(typeDefinition)).when(container).getTypeDefinitions();
- assertEquals(typeDefinition,
- YangSchemaUtils.findTypeDefinition(context, SchemaPath.create(ImmutableList.of(Q_NAME), false)));
+ assertEquals(typeDefinition, YangSchemaUtils.findTypeDefinition(context, SchemaPath.create(false, Q_NAME)));
final GroupingDefinition grouping = mock(GroupingDefinition.class);
doReturn(Q_NAME).when(grouping).getQName();
doReturn(ImmutableSet.of(grouping)).when(container).getGroupings();
doReturn(ImmutableSet.of(typeDefinition)).when(grouping).getTypeDefinitions();
- assertEquals(typeDefinition,
- YangSchemaUtils.findTypeDefinition(context, SchemaPath.create(ImmutableList.of(Q_NAME, Q_NAME), false)));
+ assertEquals(typeDefinition, YangSchemaUtils.findTypeDefinition(context,
+ SchemaPath.create(false, Q_NAME, Q_NAME)));
final DataNodeContainer dataNode =
mock(DataNodeContainer.class, withSettings().extraInterfaces(DataSchemaNode.class));
doReturn(dataNode).when(container).getDataChildByName((QName) any());
doReturn(ImmutableSet.of(typeDefinition)).when(dataNode).getTypeDefinitions();
- assertEquals(typeDefinition,
- YangSchemaUtils.findTypeDefinition(context, SchemaPath.create(ImmutableList.of(Q_NAME, Q_NAME), false)));
+ assertEquals(typeDefinition, YangSchemaUtils.findTypeDefinition(context,
+ SchemaPath.create(false, Q_NAME, Q_NAME)));
final ChoiceSchemaNode choiceNode =
mock(ChoiceSchemaNode.class, withSettings().extraInterfaces(DataSchemaNode.class));
final CaseSchemaNode caseNode = mock(CaseSchemaNode.class);
doReturn(caseNode).when(choiceNode).getCaseNodeByName((QName) any());
doReturn(ImmutableSet.of(typeDefinition)).when(caseNode).getTypeDefinitions();
- assertEquals(typeDefinition,
- YangSchemaUtils.findTypeDefinition(context,
- SchemaPath.create(ImmutableList.of(Q_NAME, Q_NAME, Q_NAME), false)));
+ assertEquals(typeDefinition, YangSchemaUtils.findTypeDefinition(context,
+ SchemaPath.create(false, Q_NAME, Q_NAME, Q_NAME)));
}
- @Test(expected = UnsupportedOperationException.class)
- public void privateConstructTest() throws Throwable {
+ @Test
+ public void privateConstructTest() throws ReflectiveOperationException {
final Constructor<YangSchemaUtils> constructor = YangSchemaUtils.class.getDeclaredConstructor();
constructor.setAccessible(true);
try {
constructor.newInstance();
+ fail();
} catch (InvocationTargetException e) {
- throw e.getCause();
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
}
}
}
@Test
public void testSortMethod() {
- GroupingDefinitionDependencySort groupingDefinitionDependencySort = new GroupingDefinitionDependencySort();
- List<GroupingDefinition> unsortedGroupingDefs = new ArrayList<>();
+ final GroupingDefinitionDependencySort groupingDefinitionDependencySort =
+ new GroupingDefinitionDependencySort();
+ final List<GroupingDefinition> unsortedGroupingDefs = new ArrayList<>();
GroupingDefinition grp1 = mock(GroupingDefinition.class);
doReturn(SchemaPath.create(false, QName.create("", "Cont1"), QName.create("", "Cont2"))).when(grp1).getPath();
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
/**
- * Mock LeafrefDypeDefinition implementation with non-null referenced RevisionAwareXPath.
- *
- * Although RevisionAwareXPath has implemented Override for toString to return null value to reach specific branch
+ * Mock LeafrefDypeDefinition implementation with non-null referenced RevisionAwareXPath. Although RevisionAwareXPath
+ * has implemented Override for toString to return null value to reach specific branch
* in TypeProviderImpl#provideTypeForLeafref method.
- *
- * Created by lukas on 9/17/14.
*/
public class LeafrefTypeWithNullToStringInXpath implements LeafrefTypeDefinition {
@Override
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
/**
- * Mock LeafrefDypeDefinition implementation with RevisionAwareXPath null reference
+ * Mock LeafrefDypeDefinition implementation with RevisionAwareXPath null reference.
*
* @author Lukas Sedlak <lsedlak@cisco.com>
*/
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.yang.types.NodeWrappedType;
public class NodeWrappedTypeTest {
@Test
public void test() {
- NodeWrappedType nwt1 = new NodeWrappedType("obj1");
- NodeWrappedType nwt2 = new NodeWrappedType("obj2");
- NodeWrappedType nwt3 = new NodeWrappedType("obj1");
- String str = "obj3";
+ final NodeWrappedType nwt1 = new NodeWrappedType("obj1");
+ final NodeWrappedType nwt2 = new NodeWrappedType("obj2");
+ final NodeWrappedType nwt3 = new NodeWrappedType("obj1");
+ final String str = "obj3";
assertTrue("Node nwt1 should equal to itself.", nwt1.equals(nwt1));
assertFalse("It can't be possible to compare nwt with string.", nwt1.equals(str));
try {
assertEquals("\"default value\"", typeProvider.getTypeDefaultConstruction(leafSchemaNode, "default value"));
fail("Expected NoSuchElementException");
- } catch (Exception e) {
- assertTrue(e instanceof NoSuchElementException);
+ } catch (NoSuchElementException e) {
+ // Okay
}
// identityref type
try {
assertEquals("\"default value\"", typeProvider.getTypeDefaultConstruction(leafSchemaNode, "default value"));
fail("Expected UnsupportedOperationException");
- } catch (Exception e) {
- assertTrue(e instanceof UnsupportedOperationException);
+ } catch (UnsupportedOperationException e) {
assertEquals("Cannot get default construction for identityref type", e.getMessage());
}
}
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
- * Test Model Provider designated to load test resources and provide Schema Context
- * for testing of TypeProviderImpl
+ * Test Model Provider designated to load test resources and provide Schema Context for testing of TypeProviderImpl.
*/
public final class TypeProviderModel {
-
public static final String TEST_TYPE_PROVIDER_MODULE_NAME = "test-type-provider";
+ private TypeProviderModel() {
+
+ }
+
public static SchemaContext createTestContext() {
return YangParserTestUtils.parseYangResources(TypeProviderModel.class, "/base-yang-types.yang",
"/" + TEST_TYPE_PROVIDER_MODULE_NAME + ".yang", "/test-type-provider-b.yang");
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
/**
- * Test suite for testing public methods in TypeProviderImpl class
- *
- * @see org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl
+ * Test suite for testing public methods in TypeProviderImpl class.
*
+ * @see org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider
* @author Lukas Sedlak <lsedlak@cisco.com>
*/
@RunWith(MockitoJUnitRunner.class)
return result;
}
- /**
- * FIXME: Remove @Ignore annotation once the bug https://bugs.opendaylight.org/show_bug.cgi?id=1862 is fixed
- */
+ // FIXME: Remove @Ignore annotation once the bug https://bugs.opendaylight.org/show_bug.cgi?id=1862 is fixed
@Ignore
@Test
public void bug1862RestrictedTypedefTransformationTest() {
final AbstractTypeProvider provider = new RuntimeTypeProvider(SCHEMA_CONTEXT);
final Module baseYangTypes = resolveModule("test-type-provider");
- final TypeDefinition<?> barItemLeafrefId = resolveTypeDefinitionFromModule(baseYangTypes, "bar-item-leafref-id");
+ final TypeDefinition<?> barItemLeafrefId = resolveTypeDefinitionFromModule(baseYangTypes,
+ "bar-item-leafref-id");
assertNotNull(barItemLeafrefId);
final Type extType = provider.generatedTypeForExtendedDefinitionType(barItemLeafrefId, barItemLeafrefId);
assertEquals(null, extType);
String result = provider.getTypeDefaultConstruction(leaf, "true");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangBoolean(java.lang.Boolean.TRUE)",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangBoolean(java.lang.Boolean.TRUE)", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-empty");
result = provider.getTypeDefaultConstruction(leaf, "true");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangEmpty(java.lang.Boolean.TRUE)",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangEmpty(java.lang.Boolean.TRUE)", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-enumeration");
result = provider.getTypeDefaultConstruction(leaf, "a");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangEnumeration.A",
- result);
+ assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangEnumeration.A", result);
leaf = provideLeafForGetDefaultConstructionTestCase("direct-use-of-enum");
result = provider.getTypeDefaultConstruction(leaf, "y");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912.construction.type.test.DirectUseOfEnum.Y",
- result);
+ assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912."
+ + "construction.type.test.DirectUseOfEnum.Y", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-int8");
result = provider.getTypeDefaultConstruction(leaf, "17");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt8(java.lang.Byte.valueOf(\"17\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt8(java.lang.Byte.valueOf(\"17\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-int8-restricted");
result = provider.getTypeDefaultConstruction(leaf, "99");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt8Restricted(java.lang.Byte.valueOf(\"99\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt8Restricted(java.lang.Byte.valueOf(\"99\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-int16");
result = provider.getTypeDefaultConstruction(leaf, "1024");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt16(java.lang.Short.valueOf(\"1024\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt16(java.lang.Short.valueOf(\"1024\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-int32");
result = provider.getTypeDefaultConstruction(leaf, "1048576");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt32(java.lang.Integer.valueOf(\"1048576\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt32(java.lang.Integer.valueOf(\"1048576\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-int64");
result = provider.getTypeDefaultConstruction(leaf, "1099511627776");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt64(java.lang.Long.valueOf(\"1099511627776\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt64(java.lang.Long.valueOf(\"1099511627776\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-string");
result = provider.getTypeDefaultConstruction(leaf, "TEST");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangString(\"TEST\")",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangString(\"TEST\")", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-decimal64");
result = provider.getTypeDefaultConstruction(leaf, "1274.25");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangDecimal64(new java.math.BigDecimal(\"1274.25\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangDecimal64(new java.math.BigDecimal(\"1274.25\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-uint8");
result = provider.getTypeDefaultConstruction(leaf, "128");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangUint8(java.lang.Short.valueOf(\"128\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangUint8(java.lang.Short.valueOf(\"128\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-uint16");
result = provider.getTypeDefaultConstruction(leaf, "1048576");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangUint16(java.lang.Integer.valueOf(\"1048576\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangUint16(java.lang.Integer.valueOf(\"1048576\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-uint32");
result = provider.getTypeDefaultConstruction(leaf, "1099511627776");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangUint32(java.lang.Long.valueOf(\"1099511627776\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangUint32(java.lang.Long.valueOf(\"1099511627776\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-uint64");
result = provider.getTypeDefaultConstruction(leaf, "1208925819614629174706176");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangUint64(new java.math.BigInteger(\"1208925819614629174706176\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangUint64(new java.math.BigInteger(\"1208925819614629174706176\"))", result);
//FIXME: Is this correct scenario and correct result?
leaf = provideLeafForGetDefaultConstructionTestCase("complex-union");
result = provider.getTypeDefaultConstruction(leaf, "75");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912.ComplexUnion(\"null\".toCharArray())",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912."
+ + "ComplexUnion(\"null\".toCharArray())", result);
//FIXME: Is this correct scenario and correct result?
leaf = provideLeafForGetDefaultConstructionTestCase("complex-string-int-union");
result = provider.getTypeDefaultConstruction(leaf, "TEST_UNION_STRING_DEFAULT");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912.ComplexStringIntUnion(\"null\".toCharArray())",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912."
+ + "ComplexStringIntUnion(\"null\".toCharArray())", result);
leaf = provideLeafForGetDefaultConstructionTestCase("simple-int-types-union");
result = provider.getTypeDefaultConstruction(leaf, "2048");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangUnion(\"null\".toCharArray())",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangUnion(\"null\".toCharArray())", result);
leaf = provideLeafForGetDefaultConstructionTestCase("direct-union-leaf");
result = provider.getTypeDefaultConstruction(leaf);
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912.DirectUnionLeaf(\"128\".toCharArray())",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912."
+ + "DirectUnionLeaf(\"128\".toCharArray())", result);
final Module module = resolveModule("test-type-provider");
final QName leafUnionNode = QName.create(module.getQNameModule(), "root-union-leaf");
result = provider.getTypeDefaultConstruction(leaf);
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912.TestTypeProviderData.RootUnionLeaf(\"256\".toCharArray())",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912."
+ + "TestTypeProviderData.RootUnionLeaf(\"256\".toCharArray())", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-binary");
result = provider.getTypeDefaultConstruction(leaf, "0xffffff");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangBinary(new byte[] {-45, 23, -33, 125, -9, -33})",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangBinary(new byte[] {-45, 23, -33, 125, -9, -33})", result);
final QName leafBitsNode = QName.create(module.getQNameModule(), "root-bits-leaf");
rootNode = module.getDataChildByName(leafBitsNode);
result = provider.getTypeDefaultConstruction(leaf);
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912.TestTypeProviderData.RootBitsLeaf(true, false, false)",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.type.provider.model.rev140912."
+ + "TestTypeProviderData.RootBitsLeaf(true, false, false)", result);
leaf = provideLeafForGetDefaultConstructionTestCase("yang-bits");
result = provider.getTypeDefaultConstruction(leaf, "only-10-Mb");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangBits(false, false, true)",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangBits(false, false, true)", result);
leaf = provideLeafForGetDefaultConstructionTestCase("bar-id");
result = provider.getTypeDefaultConstruction(leaf, "128");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt16(java.lang.Short.valueOf(\"128\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt16(java.lang.Short.valueOf(\"128\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("foo-leafref-value");
result = provider.getTypeDefaultConstruction(leaf, "32");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914.YangInt8(java.lang.Byte.valueOf(\"32\"))",
- result);
+ assertEquals("new org.opendaylight.yang.gen.v1.urn.opendaylight.org.test.base.yang.types.rev140914."
+ + "YangInt8(java.lang.Byte.valueOf(\"32\"))", result);
leaf = provideLeafForGetDefaultConstructionTestCase("foo-cond-bar-item");
result = provider.getTypeDefaultConstruction(leaf, "10");
assertNotNull(result);
assertTrue(!result.isEmpty());
- assertEquals("new java.lang.Object()",
- result);
+ assertEquals("new java.lang.Object()", result);
}
}