From 8b44908cc3d955aa2899887eba6a3400cb2f5cbb Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 11 Oct 2018 15:39:22 +0200 Subject: [PATCH] Fix checkstyle in mdsal-binding-generator-impl This fixes violations and flips enforcement on. Change-Id: Ida4e62f4c3ddf4d7d8066f3858e6ab98f0f92cf1 Signed-off-by: Robert Varga --- binding/mdsal-binding-generator-impl/pom.xml | 7 + .../generator/impl/AbstractTypeGenerator.java | 484 ++++++------------ .../generator/impl/BindingGeneratorImpl.java | 26 +- .../impl/BindingSchemaContextUtils.java | 41 +- .../binding/generator/impl/ModuleContext.java | 66 ++- .../impl/ModuleInfoBackedContext.java | 6 +- .../impl/TransformerGeneratorException.java | 5 +- .../generator/util/BindingRuntimeContext.java | 40 +- .../util/CodeGenerationException.java | 12 +- .../util/DefaultSourceCodeGenerator.java | 17 +- .../generator/util/JavassistUtils.java | 1 + .../util/SourceCodeGeneratorFactory.java | 1 + .../generator/util/YangSchemaUtils.java | 6 +- .../yang/types/AbstractTypeProvider.java | 393 ++++++-------- .../binding/yang/types/BaseYangTypes.java | 90 ++-- .../yang/types/CodegenTypeProvider.java | 2 +- .../GroupingDefinitionDependencySort.java | 54 +- .../binding/yang/types/NodeWrappedType.java | 22 +- .../impl/AugmentRelativeXPathTest.java | 16 +- .../generator/impl/AugmentedTypeTest.java | 17 +- .../generator/impl/BinaryTypeTest.java | 11 +- .../impl/BindingGeneratorImplTest.java | 52 +- .../impl/BitAndUnionTOEnclosingTest.java | 6 +- .../impl/ChoiceCaseGenTypesTest.java | 13 +- .../generator/impl/CodecTypeUtilsTest.java | 11 +- .../impl/GeneratedTypesStringTest.java | 8 +- .../generator/impl/IdentityrefTypeTest.java | 9 +- .../generator/impl/SupportTestUtil.java | 11 +- .../impl/TypeProviderIntegrationTest.java | 185 +++---- .../generator/impl/UnionTypeDefTest.java | 2 + .../binding/generator/impl/UsesTest.java | 16 +- .../generator/impl/YangTextTemplateTest.java | 11 +- .../generator/util/YangSchemaUtilsTest.java | 25 +- .../GroupingDefinitionDependencySortTest.java | 5 +- .../LeafrefTypeWithNullToStringInXpath.java | 7 +- .../yang/types/LeafrefTypeWithNullXpath.java | 2 +- .../yang/types/NodeWrappedTypeTest.java | 9 +- .../yang/types/TypeProviderImplTest.java | 7 +- .../binding/yang/types/TypeProviderModel.java | 8 +- .../binding/yang/types/TypeProviderTest.java | 115 ++--- 40 files changed, 786 insertions(+), 1033 deletions(-) diff --git a/binding/mdsal-binding-generator-impl/pom.xml b/binding/mdsal-binding-generator-impl/pom.xml index ff44717198..be8790c5e9 100644 --- a/binding/mdsal-binding-generator-impl/pom.xml +++ b/binding/mdsal-binding-generator-impl/pom.xml @@ -75,6 +75,13 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java index fd242571c9..f0da9644c9 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypeGenerator.java @@ -159,10 +159,9 @@ abstract class AbstractTypeGenerator { private final Map 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> genTypeBuilders = new HashMap<>(); @@ -172,8 +171,7 @@ abstract class AbstractTypeGenerator { 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; @@ -693,23 +691,14 @@ abstract class AbstractTypeGenerator { } /** - * Adds enumeration builder created from enumTypeDef to - * typeBuilder. + * Adds enumeration builder created from enumTypeDef to typeBuilder. Each + * enumTypeDef item is added to builder with its name and value. * - * Each enumTypeDef 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 - * enumTypeDef + * @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 enumTypeDef */ private EnumBuilder resolveInnerEnumFromTypeDefinition(final EnumTypeDefinition enumTypeDef, final QName enumName, final GeneratedTypeBuilder typeBuilder, final ModuleContext context) { @@ -726,16 +715,10 @@ abstract class AbstractTypeGenerator { /** * Generates type builder for module. * - * @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 - * module. - * @throws IllegalArgumentException - * if module 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 module. + * @throws IllegalArgumentException if module is null */ private GeneratedTypeBuilder moduleTypeBuilder(final ModuleContext context, final String postfix) { final Module module = context.module(); @@ -749,20 +732,13 @@ abstract class AbstractTypeGenerator { } /** - * Converts augSchema to list of Type which - * contains generated type for augmentation. In addition there are also - * generated types for all containers, list and choices which are child of - * augSchema node or a generated types for cases are added if - * augmented node is choice. + * Converts augSchema to list of Type which contains generated type for augmentation. + * In addition there are also generated types for all containers, list and choices which are child of + * augSchema 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 *
    *
  • if augmentPackageName equals null
  • @@ -861,10 +837,8 @@ abstract class AbstractTypeGenerator { /** * 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) { @@ -907,24 +881,14 @@ abstract class AbstractTypeGenerator { } /** - * 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, @@ -965,11 +929,6 @@ abstract class AbstractTypeGenerator { return addRawAugmentGenTypeDefinition(context, context.modulePackageName(), targetTypeRef, augSchema); } - /** - * - * @param unknownSchemaNodes - * @return nodeParameter of UnknownSchemaNode - */ private static String getAugmentIdentifier(final List unknownSchemaNodes) { for (final UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) { final QName nodeType = unknownSchemaNode.getNodeType(); @@ -982,15 +941,11 @@ abstract class AbstractTypeGenerator { } /** - * 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 builders, final String genTypeName) { @@ -1004,27 +959,19 @@ abstract class AbstractTypeGenerator { } /** - * Adds the methods to typeBuilder which represent subnodes of - * node for which typeBuilder was created. - * - * The subnodes aren't mapped to the methods if they are part of grouping or - * augment (in this case are already part of them). + * Adds the methods to typeBuilder which represent subnodes of node for which typeBuilder + * was created. The subnodes aren't mapped to the methods if they are part of grouping or augment (in this case are + * already part of them). * - * @param module - * current module - * @param parent - * generated type builder which represents any node. The subnodes - * of this node are added to the typeBuilder as - * methods. The subnode can be of type leaf, leaf-list, list, - * container, choice. - * @param childOf - * parent type - * @param schemaNodes - * set of data schema nodes which are the children of the node - * for which typeBuilder was created - * @return generated type builder which is the same builder as input - * parameter. The getter methods (representing child nodes) could be - * added to it. + * @param module current module + * @param parent generated type builder which represents any node. The subnodes of this node are added + * to the typeBuilder as methods. The subnode can be of type leaf, leaf-list, list, + * container, choice. + * @param childOf parent type + * @param schemaNodes set of data schema nodes which are the children of the node for which + * typeBuilder was created + * @return generated type builder which is the same builder as input parameter. The getter methods (representing + * child nodes) could be added to it. */ private GeneratedTypeBuilder resolveDataSchemaNodes(final ModuleContext context, final GeneratedTypeBuilder parent, final @Nullable Type childOf, final Iterable schemaNodes) { @@ -1040,24 +987,18 @@ abstract class AbstractTypeGenerator { } /** - * Adds the methods to typeBuilder what represents subnodes of - * node for which typeBuilder was created. + * Adds the methods to typeBuilder what represents subnodes of node for which typeBuilder + * was created. * - * @param module - * current module - * @param typeBuilder - * generated type builder which represents any node. The subnodes - * of this node are added to the typeBuilder as - * methods. The subnode can be of type leaf, leaf-list, list, - * container, choice. - * @param childOf - * parent type - * @param schemaNodes - * set of data schema nodes which are the children of the node - * for which typeBuilder was created - * @return generated type builder which is the same object as the input - * parameter typeBuilder. The getter method could be - * added to it. + * @param module current module + * @param typeBuilder generated type builder which represents any node. The subnodes of this node are added + * to the typeBuilder as methods. The subnode can be of type leaf, leaf-list, list, + * container, choice. + * @param childOf parent type + * @param schemaNodes set of data schema nodes which are the children of the node for which typeBuilder + * was created + * @return generated type builder which is the same object as the input parameter typeBuilder. + * The getter method could be added to it. */ private GeneratedTypeBuilder augSchemaNodeToMethods(final ModuleContext context, final GeneratedTypeBuilder typeBuilder, final Iterable schemaNodes) { @@ -1073,19 +1014,12 @@ abstract class AbstractTypeGenerator { } /** - * Adds to typeBuilder a method which is derived from - * schemaNode. + * Adds to typeBuilder a method which is derived from schemaNode. * - * @param node - * data schema node which is added to typeBuilder as - * a method - * @param typeBuilder - * generated type builder to which is schemaNode - * added as a method. - * @param childOf - * parent type - * @param module - * current module + * @param node data schema node which is added to typeBuilder as a method + * @param typeBuilder generated type builder to which is schemaNode 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) { @@ -1109,22 +1043,15 @@ abstract class AbstractTypeGenerator { } /** - * Converts choiceNode to the list of generated types for - * choice and its cases. - * - * The package names for choice and for its cases are created as - * concatenation of the module package (basePackageName) and - * names of all parents node. + * Converts choiceNode to the list of generated types for choice and its cases. The package names + * for choice and for its cases are created as concatenation of the module package (basePackageName) + * and names of all parents node. * - * @param 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 *
      *
    • if basePackageName is null
    • @@ -1151,19 +1078,14 @@ abstract class AbstractTypeGenerator { } /** - * Converts caseNodes set to list of corresponding generated types. - * - * For every case which isn't added through augment or uses is created generated type builder. - * The package names for the builder is created as concatenation of the module package and names of all parents - * nodes of the concrete case. There is also relation "implements type" between every case builder - * and choice type + * Converts caseNodes set to list of corresponding generated types. For every case which is not + * added through augment or uses 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 case. There + * is also relation "implements type" between every case builder and choice type * - * @param context - * current module context - * @param refChoiceType - * type which represents superior case - * @param choiceNode - * choice case node which is mapped to generated type + * @param context current module context + * @param refChoiceType type which represents superior case + * @param choiceNode choice case node which is mapped to generated type * @throws IllegalArgumentException *
        *
      • if refChoiceType equals null
      • @@ -1217,30 +1139,24 @@ abstract class AbstractTypeGenerator { } 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 *
          *
        • if basePackageName is null
        • @@ -1339,17 +1255,11 @@ abstract class AbstractTypeGenerator { } /** - * Converts leaf to the getter method which is added to - * typeBuilder. + * Converts leaf to the getter method which is added to typeBuilder. * - * @param typeBuilder - * generated type builder to which is added getter method as - * leaf mapping - * @param leaf - * leaf schema node which is mapped as getter method which is - * added to typeBuilder - * @param module - * Module in which type was defined + * @param typeBuilder generated type builder to which is added getter method as leaf mapping + * @param leaf leaf schema node which is mapped as getter method which is added to typeBuilder + * @param module Module in which type was defined * @return boolean value *
            *
          • false - if leaf or typeBuilder are @@ -1508,19 +1418,12 @@ abstract class AbstractTypeGenerator { } /** - * Converts leaf schema node to property of generated TO - * builder. + * Converts leaf schema node to property of generated TO builder. * - * @param toBuilder - * generated TO builder to which is leaf added as - * property - * @param leaf - * leaf schema node which is added to toBuilder 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 leaf added as property + * @param leaf leaf schema node which is added to toBuilder as property + * @param returnType property type + * @param isReadOnly boolean value which says if leaf property is|isn't read only * @return boolean value *
              *
            • false - if leaf, toBuilder or leaf @@ -1546,15 +1449,10 @@ abstract class AbstractTypeGenerator { } /** - * Converts node leaf list schema node to getter method of - * typeBuilder. + * Converts node leaf list schema node to getter method of typeBuilder. * - * @param typeBuilder - * generated type builder to which is node added as - * getter method - * @param node - * leaf list schema node which is added to - * typeBuilder as getter method + * @param typeBuilder generated type builder to which is node added as getter method + * @param node leaf list schema node which is added to typeBuilder as getter method * @param module module * @return boolean value *
                @@ -1659,26 +1557,17 @@ abstract class AbstractTypeGenerator { } /** - * Instantiates generated type builder with packageName and - * schemaNode. - * - * The new builder always implements - * {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.
                - * If schemaNode is instance of GroupingDefinition it also - * implements {@link org.opendaylight.yangtools.yang.binding.Augmentable - * Augmentable}.
                + * Instantiates generated type builder with packageName and schemaNode. The new builder + * always implements {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.
                + * If schemaNode is instance of GroupingDefinition it also implements + * {@link org.opendaylight.yangtools.yang.binding.Augmentable Augmentable}.
                * If schemaNode is instance of - * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer - * DataNodeContainer} it can also implement nodes which are specified in - * uses. + * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer DataNodeContainer} it can also implement nodes + * which are specified in uses. * - * @param packageName - * string with the name of the package to which - * schemaNode belongs. - * @param schemaNode - * schema node for which is created generated type builder - * @param parent - * parent type (can be null) + * @param packageName string with the name of the package to which schemaNode belongs. + * @param schemaNode schema node for which is created generated type builder + * @param parent parent type (can be null) * @return generated type builder schemaNode */ private GeneratedTypeBuilder addDefaultInterfaceDefinition(final String packageName, final SchemaNode schemaNode, @@ -1706,11 +1595,8 @@ abstract class AbstractTypeGenerator { /** * 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 schemaNode */ private GeneratedTypeBuilder addRawInterfaceDefinition(final ModuleContext context, final SchemaNode schemaNode, @@ -1721,20 +1607,13 @@ abstract class AbstractTypeGenerator { } /** - * Returns reference to generated type builder for specified - * schemaNode with packageName. - * - * Firstly the generated type builder is searched in - * {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. If it isn't - * found it is created and added to genTypeBuilders. + * Returns reference to generated type builder for specified schemaNode with packageName. + * Firstly the generated type builder is searched in {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. + * If it is not found it is created and added to genTypeBuilders. * - * @param packageName - * string with the package name to which returning generated type - * builder belongs - * @param schemaNode - * schema node which provide data about the schema node name - * @param 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 schemaNode * @throws IllegalArgumentException *
                  @@ -1743,7 +1622,6 @@ abstract class AbstractTypeGenerator { *
                • if QName of schema node is null
                • *
                • if schemaNode name is null
                • *
                - * */ private GeneratedTypeBuilder addRawInterfaceDefinition(final JavaTypeName identifier, final SchemaNode schemaNode) { checkArgument(schemaNode != null, "Data Schema Node cannot be NULL."); @@ -1779,12 +1657,9 @@ abstract class AbstractTypeGenerator { /** * Creates the name of the getter method name from localName. * - * @param localName - * string with the name of the getter method - * @param returnType - * return type - * @return string with the name of the getter method for - * methodName 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 methodName in JAVA method format */ public static String getterMethodName(final String localName, final Type returnType) { final StringBuilder method = new StringBuilder(); @@ -1799,10 +1674,9 @@ abstract class AbstractTypeGenerator { } /** - * Created a method signature builder as part of interfaceBuilder. - * - * The method signature builder is created for the getter method of schemaNodeName. - * Also comment and returnType information are added to the builder. + * Created a method signature builder as part of interfaceBuilder. The method signature builder is + * created for the getter method of schemaNodeName. Also comment + * and returnType 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 @@ -1828,23 +1702,16 @@ abstract class AbstractTypeGenerator { } /** - * Adds schemaNode to typeBuilder as getter method - * or to genTOBuilder as property. + * Adds schemaNode to typeBuilder as getter method or to genTOBuilder + * as a property. * - * @param basePackageName - * string contains the module package name - * @param schemaNode - * data schema node which should be added as getter method to - * typeBuilder or as a property to - * genTOBuilder if is part of the list key - * @param typeBuilder - * generated type builder for the list schema node - * @param genTOBuilder - * generated TO builder for the list keys - * @param listKeys - * list of string which contains 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 typeBuilder + * or as a property to genTOBuilder if is part of the list key + * @param typeBuilder generated type builder for the list schema node + * @param genTOBuilder generated TO builder for the list keys + * @param listKeys list of string which contains names of the list keys + * @param module current module * @throws IllegalArgumentException *
                  *
                • if schemaNode equals null
                • @@ -1896,14 +1763,11 @@ abstract class AbstractTypeGenerator { } /** - * Selects the names of the list keys from list and returns - * them as the list of the strings + * Selects the names of the list keys from list 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 - * list 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 list contains no keys then + * an empty list is returned. */ private static List listKeys(final ListSchemaNode list) { final List listKeys = new ArrayList<>(); @@ -1918,16 +1782,12 @@ abstract class AbstractTypeGenerator { } /** - * Generates for the list which contains any list keys special - * generated TO builder. + * Generates for the list 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 - * list or null if list 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 list or null if list 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()) { @@ -1939,22 +1799,14 @@ abstract class AbstractTypeGenerator { } /** - * 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 typeBuilder 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 typeBuilder as * enclosing transfer objects. * - * @param typeDef - * type definition which can be of type UnionType or - * BitsTypeDefinition - * @param typeBuilder - * generated type builder to which is added generated TO created - * from typeDef - * @param leaf - * string with name for generated TO builder - * @param parentModule - * parent module + * @param typeDef type definition which can be of type UnionType or BitsTypeDefinition + * @param typeBuilder generated type builder to which is added generated TO created from typeDef + * @param leaf string with name for generated TO builder + * @param parentModule parent module * @return generated TO builder for typeDef */ private Type addTOToTypeBuilder(final UnionTypeDefinition typeDef, @@ -1980,23 +1832,15 @@ abstract class AbstractTypeGenerator { } /** - * Builds generated TO builders for typeDef of type {@link BitsTypeDefinition} which are - * also added to typeBuilder as enclosing transfer object. + * Builds generated TO builders for typeDef of type {@link BitsTypeDefinition} which are also added + * to typeBuilder 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 typeBuilder 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 typeBuilder as - * enclosing transfer objects. - * - * @param typeDef - * type definition which can be of type UnionType or - * BitsTypeDefinition - * @param typeBuilder - * generated type builder to which is added generated TO created - * from typeDef - * @param leaf - * string with name for generated TO builder - * @param parentModule - * parent module + * @param typeDef type definition which can be of type UnionType or BitsTypeDefinition + * @param typeBuilder generated type builder to which is added generated TO created from typeDef + * @param leaf string with name for generated TO builder + * @param parentModule parent module * @return generated TO builder for typeDef */ private GeneratedTOBuilder addTOToTypeBuilder(final BitsTypeDefinition typeDef, @@ -2010,19 +1854,13 @@ abstract class AbstractTypeGenerator { } /** - * Adds the implemented types to type builder. - * - * The method passes through the list of uses in - * {@code dataNodeContainer}. For every use is obtained corresponding - * generated type from {@link ModuleContext#groupings - * allGroupings} which is added as implements type to - * builder + * Adds the implemented types to type builder. The method passes through the list of uses in + * {@code dataNodeContainer}. For every use is obtained corresponding generated type + * from {@link ModuleContext#groupings allGroupings} which is added as implements type + * to builder * - * @param dataNodeContainer - * element which contains the list of used YANG groupings - * @param builder - * builder to which are added implemented types according to - * dataNodeContainer + * @param dataNodeContainer element which contains the list of used YANG groupings + * @param builder builder to which are added implemented types according to dataNodeContainer * @return generated type builder with all implemented types */ private GeneratedTypeBuilder addImplementedInterfaceFromUses(final DataNodeContainer dataNodeContainer, diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java index b53ec144f6..4a7818b864 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java @@ -32,18 +32,12 @@ public class BindingGeneratorImpl implements BindingGenerator, BindingRuntimeGen private static final Logger LOG = LoggerFactory.getLogger(BindingGeneratorImpl.class); /** - * Resolves generated types from context schema nodes only for - * modules specified in modules + * Resolves generated types from context schema nodes only for modules specified + * in modules. 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 GeneratedType or * GeneratedTransferObject) which: *
                    @@ -93,13 +87,13 @@ public class BindingGeneratorImpl implements BindingGenerator, BindingRuntimeGen checkState(context.getModules() != null, "Schema Context does not contain defined modules."); } - private static void rename(final Map renames, final RenameMappingException e) { - final JavaTypeName name = e.getName(); - final SchemaNode def = e.getDefinition(); + private static void rename(final Map 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; @@ -110,7 +104,7 @@ public class BindingGeneratorImpl implements BindingGenerator, BindingRuntimeGen } 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); diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingSchemaContextUtils.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingSchemaContextUtils.java index ed840b0b63..660f64aef0 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingSchemaContextUtils.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingSchemaContextUtils.java @@ -5,7 +5,6 @@ * 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; @@ -33,8 +32,11 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition; 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"); @@ -53,7 +55,7 @@ public final class BindingSchemaContextUtils { 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 { @@ -64,13 +66,14 @@ public final class BindingSchemaContextUtils { 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()); @@ -85,15 +88,6 @@ public final class BindingSchemaContextUtils { return currentContainer; } - private static Optional 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 Optional findDataNodeContainer(final DataNodeContainer ctx, final QName targetQName) { @@ -115,6 +109,16 @@ public final class BindingSchemaContextUtils { return Optional.empty(); } + private static Optional 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 potential = findDataNodeContainer(caze, targetQName); @@ -125,6 +129,7 @@ public final class BindingSchemaContextUtils { return null; } + @SuppressWarnings("checkstyle:illegalCatch") private static Optional findFirstDataNodeContainerInRpc(final SchemaContext ctx, final Class targetType) { final QNameModule targetModule; @@ -156,17 +161,15 @@ public final class BindingSchemaContextUtils { if (targetType.equals(rpcOutputName)) { return Optional.of(rpc.getOutput()); } - return Optional.empty(); + return Optional.empty(); } public static Set collectAllAugmentationDefinitions(final SchemaContext currentSchema, final AugmentationTarget ctxNode) { HashSet 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; @@ -190,7 +193,7 @@ public final class BindingSchemaContextUtils { public static Optional 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) { diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleContext.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleContext.java index 872529db75..c938f5e11a 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleContext.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleContext.java @@ -129,39 +129,39 @@ public final class ModuleContext { 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)) { @@ -172,24 +172,24 @@ public final class ModuleContext { 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 getTypedefs() { @@ -240,9 +240,8 @@ public final class ModuleContext { } /** - * 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 */ @@ -256,9 +255,6 @@ public final class ModuleContext { /** * 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); diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleInfoBackedContext.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleInfoBackedContext.java index 7e8bd2e6b2..1d112ccb3f 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleInfoBackedContext.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/ModuleInfoBackedContext.java @@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy +public final class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy implements ModuleInfoRegistry, SchemaContextProvider, SchemaSourceProvider { private final YangTextSchemaContextResolver ctxResolver = YangTextSchemaContextResolver.create("binding-context"); @@ -89,6 +89,7 @@ public class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy return ctxResolver.getSchemaContext(); } + @SuppressWarnings("checkstyle:illegalCatch") private boolean resolveModuleInfo(final Class cls) { try { return resolveModuleInfo(BindingReflections.getModuleInfo(cls)); @@ -97,6 +98,7 @@ public class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy } } + @SuppressWarnings("checkstyle:illegalCatch") private boolean resolveModuleInfo(final YangModuleInfo moduleInfo) { SourceIdentifier identifier = sourceIdentifierFrom(moduleInfo); @@ -163,7 +165,7 @@ public class ModuleInfoBackedContext extends GeneratedClassLoadingStrategy private final ModuleInfoBackedContext context; - public YangModuleInfoRegistration(final YangModuleInfo instance, final ModuleInfoBackedContext context) { + YangModuleInfoRegistration(final YangModuleInfo instance, final ModuleInfoBackedContext context) { super(instance); this.context = context; } diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/TransformerGeneratorException.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/TransformerGeneratorException.java index e362c2b0ad..cced142c24 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/TransformerGeneratorException.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/TransformerGeneratorException.java @@ -10,11 +10,12 @@ package org.opendaylight.mdsal.binding.generator.impl; 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); } } diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingRuntimeContext.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingRuntimeContext.java index 55b8114d5d..a2ca55bf24 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingRuntimeContext.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingRuntimeContext.java @@ -252,10 +252,6 @@ public final class BindingRuntimeContext implements Immutable { 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 @@ -329,6 +325,22 @@ public final class BindingRuntimeContext implements Immutable { return getEnumMapping(findTypeWithSchema(enumClassName)); } + private static BiMap getEnumMapping(final Entry typeWithSchema) { + final TypeDefinition typeDef = (TypeDefinition) typeWithSchema.getValue(); + + Preconditions.checkArgument(typeDef instanceof EnumTypeDefinition); + final EnumTypeDefinition enumType = (EnumTypeDefinition) typeDef; + + final HashBiMap 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 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 @@ -375,22 +387,6 @@ public final class BindingRuntimeContext implements Immutable { throw new IllegalArgumentException("Failed to find type for " + className); } - private static BiMap getEnumMapping(final Entry typeWithSchema) { - final TypeDefinition typeDef = (TypeDefinition) typeWithSchema.getValue(); - - Preconditions.checkArgument(typeDef instanceof EnumTypeDefinition); - final EnumTypeDefinition enumType = (EnumTypeDefinition) typeDef; - - final HashBiMap 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> getCases(final Class choice) { final Collection cazes = runtimeTypes.findCases(referencedType(choice)); final Set> ret = new HashSet<>(cazes.size()); @@ -449,6 +445,10 @@ public final class BindingRuntimeContext implements Immutable { 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; diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/CodeGenerationException.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/CodeGenerationException.java index 62df6f0b21..a115b953d4 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/CodeGenerationException.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/CodeGenerationException.java @@ -7,26 +7,26 @@ */ 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); } } diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/DefaultSourceCodeGenerator.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/DefaultSourceCodeGenerator.java index b873eb2624..2e97ecb476 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/DefaultSourceCodeGenerator.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/DefaultSourceCodeGenerator.java @@ -11,13 +11,13 @@ package org.opendaylight.mdsal.binding.generator.util; 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 @@ -42,17 +42,16 @@ public class DefaultSourceCodeGenerator implements SourceCodeGenerator { * is obtained from a system property (org.opendaylight.yangtools.sal.generatedCodecSourceDir) 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())) @@ -69,7 +68,7 @@ public class DefaultSourceCodeGenerator implements SourceCodeGenerator { } @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())) @@ -94,7 +93,7 @@ public class DefaultSourceCodeGenerator implements SourceCodeGenerator { } @Override - public void outputGeneratedSource(CtClass ctClass) { + public void outputGeneratedSource(final CtClass ctClass) { String name = ctClass.getName(); StringBuilder classBuilder = new StringBuilder(); diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/JavassistUtils.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/JavassistUtils.java index 8dd1057719..a2c6456c01 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/JavassistUtils.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/JavassistUtils.java @@ -67,6 +67,7 @@ public final class JavassistUtils { * @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); diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/SourceCodeGeneratorFactory.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/SourceCodeGeneratorFactory.java index e4b26e9095..d26006e882 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/SourceCodeGeneratorFactory.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/SourceCodeGeneratorFactory.java @@ -21,6 +21,7 @@ public class SourceCodeGeneratorFactory { /** * Gets a SourceCodeGenerator instance. + * *

                    * Generation of source code is controlled by the org.opendaylight.yangtools.sal.generateCodecSource * system property. If set to true, a DefaultSourceCodeGenerator instance is returned, otherwise a diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java index 9b9680f173..5386a77593 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java @@ -64,8 +64,8 @@ public final class YangSchemaUtils { } 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(); } } @@ -78,7 +78,7 @@ public final class YangSchemaUtils { 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. diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java index 74a65c8c39..0d1ddac048 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java @@ -18,7 +18,6 @@ import com.google.common.base.Strings; 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; @@ -104,9 +103,6 @@ public abstract class AbstractTypeProvider implements TypeProvider { */ private final SchemaContext schemaContext; - /** - * Map>> - */ private final Map, Map>> genTypeDefsContextMap = new HashMap<>(); /** @@ -119,27 +115,22 @@ public abstract class AbstractTypeProvider implements TypeProvider { /** * Creates new instance of class TypeProviderImpl. * - * @param schemaContext - * contains the schema data red from YANG files - * @param renames - * @throws IllegalArgumentException - * if schemaContext equal null. + * @param schemaContext contains the schema data red from YANG files + * @param renames renaming table + * @throws IllegalArgumentException if schemaContext equal null. */ AbstractTypeProvider(final SchemaContext schemaContext, final Map renames) { Preconditions.checkArgument(schemaContext != null, "Schema Context cannot be null!"); - this.schemaContext = schemaContext; this.renames = requireNonNull(renames); resolveTypeDefsFromContext(); } /** - * Puts refType to map with key refTypePath + * Puts refType to map with key refTypePath. * - * @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 *

                      *
                    • if refTypePath equal null
                    • @@ -164,11 +155,9 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Converts schema definition type typeDefinition to JAVA - * Type + * Converts schema definition type typeDefinition to JAVA Type. * - * @param typeDefinition - * type definition which is converted to JAVA type + * @param typeDefinition type definition which is converted to JAVA type * @throws IllegalArgumentException *
                        *
                      • if typeDefinition equal null
                      • @@ -178,7 +167,7 @@ public abstract class AbstractTypeProvider implements TypeProvider { */ @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!)"); @@ -192,7 +181,7 @@ public abstract class AbstractTypeProvider implements TypeProvider { // 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; } @@ -214,7 +203,7 @@ public abstract class AbstractTypeProvider implements TypeProvider { } 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()); @@ -223,19 +212,20 @@ public abstract class AbstractTypeProvider implements TypeProvider { 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()); @@ -292,12 +282,10 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Returns JAVA Type for instances of the type - * LeafrefTypeDefinition or + * Returns JAVA Type for instances of the type LeafrefTypeDefinition or * IdentityrefTypeDefinition. * - * @param typeDefinition - * type definition which is converted to JAVA Type + * @param typeDefinition type definition which is converted to JAVA Type * @return JAVA Type instance for typeDefinition */ private Type javaTypeForLeafrefOrIdentityRef(final TypeDefinition typeDefinition, final SchemaNode parentNode) { @@ -314,11 +302,9 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Returns JAVA Type for instances of the type - * ExtendedType. + * Returns JAVA Type for instances of the type ExtendedType. * - * @param typeDefinition - * type definition which is converted to JAVA Type + * @param typeDefinition type definition which is converted to JAVA Type * @return JAVA Type instance for typeDefinition */ private Type javaTypeForExtendedType(final TypeDefinition typeDefinition) { @@ -350,19 +336,15 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Seeks for identity reference idref the JAVA - * type.
                        - *
                        + * Seeks for identity reference idref the JAVA type. * + *

                        * Example:
                        * If identy which is referenced via idref has name Idn * then returning type is {@code Class}
                        * - * @param idref - * identityref type definition for which JAVA Type - * is sought - * @return JAVA Type of the identity which is referenced through - * idref + * @param idref identityref type definition for which JAVA Type is sought + * @return JAVA Type of the identity which is referenced through idref */ private Type provideTypeForIdentityref(final IdentityrefTypeDefinition idref) { final Collection identities = idref.getIdentities(); @@ -381,8 +363,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { 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)); } @@ -401,11 +383,11 @@ public abstract class AbstractTypeProvider implements TypeProvider { *

                      • if name of typeDefinition
                      • *
                      */ - 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!"); @@ -498,15 +480,11 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Converts leafrefType to JAVA Type. - * - * The path of leafrefType is followed to find referenced node - * and its Type is returned. + * Converts leafrefType to JAVA Type. The path of leafrefType is followed + * to find referenced node and its Type is returned. * - * @param leafrefType - * leafref type definition for which is the type sought - * @return JAVA Type of data schema node which is referenced in - * leafrefType + * @param leafrefType leafref type definition for which is the type sought + * @return JAVA Type of data schema node which is referenced in leafrefType * @throws IllegalArgumentException *
                        *
                      • if leafrefType equal null
                      • @@ -515,14 +493,13 @@ public abstract class AbstractTypeProvider implements TypeProvider { * */ 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) { @@ -557,12 +534,10 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Checks if dataNode is LeafSchemaNode and if it - * so then checks if it is of type EnumTypeDefinition. + * Checks if dataNode is LeafSchemaNode and if it so then checks if it is of type + * EnumTypeDefinition. * - * @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 *
                          *
                        • true - if dataNode is leaf of type enumeration
                        • @@ -580,12 +555,10 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Checks if dataNode is LeafListSchemaNode and if - * it so then checks if it is of type EnumTypeDefinition. + * Checks if dataNode is LeafListSchemaNode and if it so then checks if it is of type + * EnumTypeDefinition. * - * @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 *
                            *
                          • true - if dataNode is leaflist of type @@ -604,16 +577,11 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Converts enumTypeDef to - * {@link Enumeration - * enumeration}. + * Converts enumTypeDef 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 enumTypeDef + * @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 enumTypeDef * @throws IllegalArgumentException *
                              *
                            • if enumTypeDef equals null
                            • @@ -643,18 +611,12 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Adds enumeration to typeBuilder. The enumeration data are - * taken from enumTypeDef. + * Adds enumeration to typeBuilder. The enumeration data are taken from enumTypeDef. * - * @param enumTypeDef - * enumeration type definition is source of enumeration data for - * typeBuilder - * @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 - * enumTypeDef + * @param enumTypeDef enumeration type definition is source of enumeration data for typeBuilder + * @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 enumTypeDef * @throws IllegalArgumentException *
                                *
                              • if enumTypeDef equals null
                              • @@ -701,14 +663,12 @@ public abstract class AbstractTypeProvider implements TypeProvider { abstract void addCodegenInformation(GeneratedTypeBuilderBase genTOBuilder, TypeDefinition typeDef); /** - * Converts the pattern constraints from typedef to the list of - * the strings which represents these constraints. + * Converts the pattern constraints from typedef 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 typedef equals null + * @throws IllegalArgumentException if typedef equals null * */ private Map resolveRegExpressionsFromTypedef(final TypeDefinition typedef) { @@ -723,8 +683,7 @@ public abstract class AbstractTypeProvider implements TypeProvider { /** * Converts dataNode to JAVA Type. * - * @param dataNode - * contains information about YANG type + * @param dataNode contains information about YANG type * @return JAVA Type representation of dataNode */ private Type resolveTypeFromDataSchemaNode(final SchemaNode dataNode) { @@ -743,18 +702,15 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * 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.
                                + *

                                + * 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.
                                * 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 modules = schemaContext.getModules(); @@ -782,14 +738,12 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** + * 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 - * typedef belongs - * @param typedef - * type definition of the node for which should be created JAVA Type (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 typedef belongs + * @param typedef type definition of the node for which should be created JAVA Type + * (usually generated TO) * @return JAVA Type representation of typedef or * null value if basePackageName or * modulName or typedef or Q name of @@ -832,7 +786,7 @@ public abstract class AbstractTypeProvider implements TypeProvider { method.setStatic(true); Set types = additionalTypes.get(module); if (types == null) { - types = Sets. newHashSet(unionBuilder.build()); + types = Sets.newHashSet(unionBuilder.build()); additionalTypes.put(module, types); } else { types.add(unionBuilder.build()); @@ -874,12 +828,9 @@ public abstract class AbstractTypeProvider implements TypeProvider { /** * 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 Type to which is typedef 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 Type to which is typedef mapped * @return generated transfer object which representjavaType */ private GeneratedTransferObject wrapJavaTypeIntoTO(final String basePackageName, final TypeDefinition typedef, @@ -925,14 +876,11 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Converts typedef to generated TO with - * typeDefName. Every union type from typedef is - * added to generated TO builder as property. + * Converts typedef to generated TO with typeDefName. Every union type from + * typedef is added to generated TO builder as property. * * @param typeName new type identifier - * @param typedef - * type definition which should be of type - * UnionTypeDefinition + * @param typedef type definition which should be of type UnionTypeDefinition * @return generated TO builder which represents typedef * @throws NullPointerException *

                                  @@ -989,20 +937,16 @@ public abstract class AbstractTypeProvider implements TypeProvider { /** * Wraps code which handles the case when union subtype is also of the type UnionType. * + *

                                  * 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 parentUnionGenTOBuilder 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 * provideGeneratedTOBuildersForUnionTypeDef method. */ private List resolveUnionSubtypeAsUnion(final GeneratedTOBuilder parentUnionGenTOBuilder, @@ -1023,23 +967,14 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Wraps code which handle case when union subtype is of the type - * ExtendedType. - * - * If TO for this type already exists it is used for the creation of the - * property in parentUnionGenTOBuilder. 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 ExtendedType 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 ExtendedType. If TO for this type + * already exists it is used for the creation of the property in parentUnionGenTOBuilder. 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 ExtendedType 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 expressions, final SchemaNode parentNode) { @@ -1078,18 +1013,17 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Searches for generated TO for searchedTypeDef type - * definition in {@link #genTypeDefsContextMap genTypeDefsContextMap} + * Searches for generated TO for searchedTypeDef type definition + * in {@link #genTypeDefsContextMap genTypeDefsContextMap}. * - * @param searchedTypeName - * string with name of searchedTypeDef - * @return generated TO for searchedTypeDef or - * null it it doesn't exist + * @param searchedTypeName string with name of searchedTypeDef + * @return generated TO for searchedTypeDef or null 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, Map> modulesByDate = genTypeDefsContextMap.get(typeModule.getName()); + final Map, Map> modulesByDate = genTypeDefsContextMap.get( + typeModule.getName()); final Map genTOs = modulesByDate.get(typeModule.getRevision()); if (genTOs != null) { return genTOs.get(searchedTypeName); @@ -1099,21 +1033,19 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Stores generated TO created from genTOBuilder for - * newTypeDef to {@link #genTypeDefsContextMap - * genTypeDefsContextMap} if the module for newTypeDef exists + * Stores generated TO created from genTOBuilder for newTypeDef + * to {@link #genTypeDefsContextMap genTypeDefsContextMap} if the module for newTypeDef exists. * - * @param newTypeDef - * type definition for which is genTOBuilder created - * @param genTOBuilder - * generated TO builder which is converted to generated TO and - * stored + * @param newTypeDef type definition for which is genTOBuilder 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, Map> modulesByDate = genTypeDefsContextMap.get(parentModule.getName()); + final Map, Map> modulesByDate = genTypeDefsContextMap.get( + parentModule.getName()); final Map genTOsMap = modulesByDate.get(parentModule.getRevision()); genTOsMap.put(newTypeDef.getQName().getLocalName(), genTOBuilder.build()); } @@ -1121,19 +1053,15 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Adds a new property with the name propertyName and with type - * type to unonGenTransObject. + * Adds a new property with the name propertyName and with type type + * to unonGenTransObject. * - * @param unionGenTransObject - * generated TO to which should be property added - * @param type - * JAVA type of the property which should be added - * to unionGentransObject - * @param propertyName - * string with name of property which should be added to - * unionGentransObject + * @param unionGenTransObject generated TO to which should be property added + * @param type JAVA type of the property which should be added to unionGentransObject + * @param propertyName string with name of property which should be added to unionGentransObject */ - 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)); @@ -1148,12 +1076,9 @@ public abstract class AbstractTypeProvider implements TypeProvider { /** * Converts typedef 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 - * typedef and basePackageName + * @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 typedef and basePackageName */ private GeneratedTOBuilder typedefToTransferObject(final String basePackageName, final TypeDefinition typedef, final String moduleName) { @@ -1172,15 +1097,12 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Converts typeDef which should be of the type - * BitsTypeDefinition to GeneratedTOBuilder. - * - * All the bits of the typeDef are added to returning generated TO as + * Converts typeDef which should be of the type BitsTypeDefinition + * to GeneratedTOBuilder. 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 typeDef * @throws IllegalArgumentException *

                                    @@ -1213,15 +1135,11 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** + * Adds to the genTOBuilder the constant which contains regular expressions from + * the regularExpressions. * - * Adds to the genTOBuilder the constant which contains regular - * expressions from the regularExpressions - * - * @param genTOBuilder - * generated TO builder to which are - * regular expressions added - * @param expressions - * list of string which represent regular expressions + * @param genTOBuilder generated TO builder to which are regular expressions added + * @param expressions list of string which represent regular expressions */ private static void addStringRegExAsConstant(final GeneratedTOBuilder genTOBuilder, final Map expressions) { @@ -1232,25 +1150,19 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * Creates generated TO with data about inner extended type - * innerExtendedType, about the package name - * typedefName and about the generated TO name - * typedefName. + * Creates generated TO with data about inner extended type innerExtendedType, about the package name + * typedefName and about the generated TO name typedefName. * - * It is supposed that innerExtendedType is already present in - * {@link AbstractTypeProvider#genTypeDefsContextMap genTypeDefsContextMap} to - * be possible set it as extended type for the returning generated TO. + *

                                    + * It is assumed that innerExtendedType 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 - * innerExtendedType + * @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 innerExtendedType * @throws IllegalArgumentException *

                                      *
                                    • if extendedType equals null
                                    • @@ -1304,11 +1216,10 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * 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()); @@ -1318,18 +1229,14 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * 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> sortTypeDefinitionAccordingDepth( final Collection> unsortedTypeDefinitions) { @@ -1352,13 +1259,10 @@ public abstract class AbstractTypeProvider implements TypeProvider { } /** - * 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 @@ -1445,7 +1349,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { 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()); } @@ -1465,12 +1370,14 @@ public abstract class AbstractTypeProvider implements TypeProvider { 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; @@ -1521,7 +1428,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { && !(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(), ')'); @@ -1566,7 +1474,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { private static final Comparator 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 bits = new ArrayList<>(type.getBits()); bits.sort(BIT_NAME_COMPARATOR); final StringBuilder sb = new StringBuilder(); @@ -1596,7 +1505,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { 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!"); @@ -1661,7 +1571,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { 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()); } } diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/BaseYangTypes.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/BaseYangTypes.java index 4aa1c23d2c..1b6470aab9 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/BaseYangTypes.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/BaseYangTypes.java @@ -25,71 +25,71 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition; 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 TYPE_MAP; /** - * Type representation of boolean YANG type + * Type representation of boolean YANG type. */ public static final Type BOOLEAN_TYPE = Types.typeForClass(Boolean.class); /** - * Type representation of empty YANG type + * Type representation of empty YANG type. */ public static final Type EMPTY_TYPE = Types.typeForClass(Boolean.class); public static final Type ENUM_TYPE = Types.typeForClass(Enum.class); /** - * Type representation of int8 YANG type + * Type representation of int8 YANG type. */ public static final Type INT8_TYPE = Types.typeForClass(Byte.class); /** - * Type representation of int16 YANG type + * Type representation of int16 YANG type. */ public static final Type INT16_TYPE = Types.typeForClass(Short.class); /** - * Type representation of int32 YANG type + * Type representation of int32 YANG type. */ public static final Type INT32_TYPE = Types.typeForClass(Integer.class); /** - * Type representation of int64 YANG type + * Type representation of int64 YANG type. */ public static final Type INT64_TYPE = Types.typeForClass(Long.class); /** - * Type representation of string YANG type + * Type representation of string YANG type. */ public static final Type STRING_TYPE = Types.typeForClass(String.class); /** - * Type representation of decimal64 YANG type + * Type representation of decimal64 YANG type. */ public static final Type DECIMAL64_TYPE = Types.typeForClass(BigDecimal.class); /** - * Type representation of uint8 YANG type + * Type representation of uint8 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)); /** - * Type representation of uint16 YANG type + * Type representation of uint16 YANG type. */ public static final Type UINT16_TYPE = Types.typeForClass(Integer.class, singleRangeRestrictions(0, 65535)); /** - * Type representation of uint32 YANG type + * Type representation of uint32 YANG type. */ public static final Type UINT32_TYPE = Types.typeForClass(Long.class, singleRangeRestrictions(0L, 4294967295L)); /** - * Type representation of uint64 YANG type + * Type representation of uint64 YANG type. */ public static final Type UINT64_TYPE = Types.typeForClass(BigInteger.class, singleRangeRestrictions(BigInteger.ZERO, new BigInteger("18446744073709551615"))); @@ -97,7 +97,7 @@ public final class BaseYangTypes { public static final Type UNION_TYPE = new UnionType(); /** - * Type representation of binary YANG type + * Type representation of binary YANG type. */ public static final Type BINARY_TYPE = Types.typeForClass(byte[].class); @@ -171,34 +171,34 @@ public final class BaseYangTypes { 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); } } diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/CodegenTypeProvider.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/CodegenTypeProvider.java index 3401f9a5fe..6f6963f709 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/CodegenTypeProvider.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/CodegenTypeProvider.java @@ -48,7 +48,7 @@ public class CodegenTypeProvider extends AbstractTypeProvider { * Creates new instance of class TypeProviderImpl. * * @param schemaContext contains the schema data read from YANG files - * @param renames + * @param renames renaming table * @throws IllegalArgumentException if schemaContext is null. */ public CodegenTypeProvider(final SchemaContext schemaContext, final Map renames) { diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySort.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySort.java index 29d8e6699c..5344c110a3 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySort.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySort.java @@ -27,15 +27,11 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.UsesNode; public class GroupingDefinitionDependencySort { - /** - * Sorts set groupingDefinitions according to the mutual - * dependencies.
                                      - * - * Elements of groupingDefinitions are firstly transformed to - * {@link TopologicalSort.Node Node} interfaces and then are sorted by - * {@link TopologicalSort#sort(Set) sort()} method of TopologicalSort.
                                      - *
                                      + * Sorts set groupingDefinitions according to the mutual dependencies.
                                      + * Elements of groupingDefinitions are firstly transformed to {@link TopologicalSort.Node Node} + * interfaces and then are sorted by {@link TopologicalSort#sort(Set) sort()} method + * of TopologicalSort.
                                      * * Definition of dependency relation:
                                      * The first GroupingDefinition object (in this context) @@ -44,18 +40,14 @@ public class GroupingDefinitionDependencySort { * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer#getUses() * getUses} method) reference to the second one.
                                      * - * @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 groupingDefinitions + * @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 groupingDefinitions * */ public List sort(final Collection 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 resultGroupingDefinitions = new ArrayList<>(); @@ -66,25 +58,16 @@ public class GroupingDefinitionDependencySort { 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 nodeFrom) is for its - * wrapped grouping definition passed the set of its uses nodes - * through. For every uses node is found its wrapping node (next as - * nodeTo). 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 nodeFrom) is for its wrapped grouping definition passed the set of its uses nodes through. + * For every uses node is found its wrapping node (next as nodeTo). 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 groupingDefinitionsToNodes(final Collection groupingDefinitions) { @@ -118,13 +101,10 @@ public class GroupingDefinitionDependencySort { } /** - * Returns the set of the uses nodes which are get from uses in - * container, from uses in groupings inside - * container and from uses inside child nodes of the - * container. + * Returns the set of the uses nodes which are get from uses in container, from uses in groupings + * inside container and from uses inside child nodes of the container. * - * @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 container. */ private Set getAllUsesNodes(final DataNodeContainer container) { diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedType.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedType.java index e0f2f64471..14dcd27af9 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedType.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedType.java @@ -11,23 +11,22 @@ import org.opendaylight.yangtools.util.TopologicalSort.NodeImpl; 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 NodeWrappedType. - * - * @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 wrappedType */ Object getWrappedType() { @@ -35,14 +34,14 @@ public final class NodeWrappedType extends NodeImpl { } @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; } @@ -58,5 +57,4 @@ public final class NodeWrappedType extends NodeImpl { public String toString() { return "NodeWrappedType{" + "wrappedType=" + wrappedType + '}'; } - } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentRelativeXPathTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentRelativeXPathTest.java index 38e997c352..660cf4ccce 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentRelativeXPathTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentRelativeXPathTest.java @@ -30,7 +30,7 @@ public class AugmentRelativeXPathTest extends AbstractTypesTest { } @Test - public void AugmentationWithRelativeXPathTest() { + public void testAugmentationWithRelativeXPath() { final SchemaContext context = YangParserTestUtils.parseYangFiles(testModels); @@ -47,15 +47,17 @@ public class AugmentRelativeXPathTest extends AbstractTypesTest { 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; } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentedTypeTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentedTypeTest.java index 7cfecf88bf..aeb4ef56ca 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentedTypeTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentedTypeTest.java @@ -48,18 +48,19 @@ public class AugmentedTypeTest { 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; } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BinaryTypeTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BinaryTypeTest.java index 18c747a6c0..c3a55b0349 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BinaryTypeTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BinaryTypeTest.java @@ -23,23 +23,22 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; public class BinaryTypeTest { - private final static List yangModels = new ArrayList<>(); - private final static URL yangModelsFolder = AugmentedTypeTest.class - .getResource("/binary-type-test-models"); + private static final List 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(); diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImplTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImplTest.java index 20467e5b31..f50a7b02ee 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImplTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImplTest.java @@ -48,24 +48,26 @@ public class BindingGeneratorImplTest { 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 } } @@ -146,12 +148,14 @@ public class BindingGeneratorImplTest { List 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 } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BitAndUnionTOEnclosingTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BitAndUnionTOEnclosingTest.java index a4f1665941..f31db1fa06 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BitAndUnionTOEnclosingTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/BitAndUnionTOEnclosingTest.java @@ -161,7 +161,8 @@ public class BitAndUnionTOEnclosingTest { 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")); @@ -174,7 +175,8 @@ public class BitAndUnionTOEnclosingTest { 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")); diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/ChoiceCaseGenTypesTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/ChoiceCaseGenTypesTest.java index b35aa6fa0b..b1fd5bc1b7 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/ChoiceCaseGenTypesTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/ChoiceCaseGenTypesTest.java @@ -65,7 +65,8 @@ public class ChoiceCaseGenTypesTest extends AbstractTypesTest { 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 @@ -153,20 +154,22 @@ public class ChoiceCaseGenTypesTest extends AbstractTypesTest { containsMethods(genType, new NameTypePattern("getStorageFormat", "StorageFormat")); containsInterface("Augmentation", 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")); 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); - } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/CodecTypeUtilsTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/CodecTypeUtilsTest.java index aefc3f386a..5e16092dd6 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/CodecTypeUtilsTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/CodecTypeUtilsTest.java @@ -8,6 +8,8 @@ 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; @@ -19,18 +21,19 @@ import org.opendaylight.yangtools.yang.binding.Identifier; 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 diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/GeneratedTypesStringTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/GeneratedTypesStringTest.java index c2069720e6..94dc87f778 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/GeneratedTypesStringTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/GeneratedTypesStringTest.java @@ -53,17 +53,17 @@ public class GeneratedTypesStringTest { } 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; } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/IdentityrefTypeTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/IdentityrefTypeTest.java index 755e92f5a3..7e51d54183 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/IdentityrefTypeTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/IdentityrefTypeTest.java @@ -47,9 +47,8 @@ public class IdentityrefTypeTest { } /** - * Test mainly for the method - * TypeProviderImpl#provideTypeForIdentityref(IdentityrefTypeDefinition) - * provideTypeForIdentityref} + * Test mainly for the method TypeProviderImpl#provideTypeForIdentityref(IdentityrefTypeDefinition) + * provideTypeForIdentityref}. */ @Test public void testIdentityrefYangBuiltInType() { @@ -85,11 +84,9 @@ public class IdentityrefTypeTest { } } } - 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); - } - } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/SupportTestUtil.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/SupportTestUtil.java index 94b0ebb039..ef897e5217 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/SupportTestUtil.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/SupportTestUtil.java @@ -18,7 +18,10 @@ import org.opendaylight.mdsal.binding.model.api.MethodSignature; 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 searchedSignsIn = genType.getMethodDefinitions(); @@ -53,8 +56,8 @@ public class SupportTestUtil { } } - 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 searchedPropertiesIn = genTO.getProperties(); containsAttributes(searchedPropertiesIn, "", searchedSignsWhat); if (equal) { @@ -113,7 +116,7 @@ public class SupportTestUtil { return nameBuilder.toString(); } - public static void containsInterface(String interfaceNameSearched, GeneratedType genType) { + public static void containsInterface(final String interfaceNameSearched, final GeneratedType genType) { List caseCImplements = genType.getImplements(); boolean interfaceFound = false; for (Type caseCImplement : caseCImplements) { diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/TypeProviderIntegrationTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/TypeProviderIntegrationTest.java index 991d476467..c40acf5ed8 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/TypeProviderIntegrationTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/TypeProviderIntegrationTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.assertNotNull; 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; @@ -27,264 +28,270 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition; 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); @@ -292,13 +299,13 @@ public class TypeProviderIntegrationTest { @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); @@ -308,8 +315,8 @@ public class TypeProviderIntegrationTest { @Test public void testGetParamNameFromType() { - m = context.findModule("ietf-inet-types", Revision.of("2010-09-24")).get(); - Set> types = m.getTypeDefinitions(); + module = CONTEXT.findModule("ietf-inet-types", Revision.of("2010-09-24")).get(); + Set> types = module.getTypeDefinitions(); TypeDefinition ipv4 = null; TypeDefinition ipv6 = null; TypeDefinition ipv4Pref = null; diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UnionTypeDefTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UnionTypeDefTest.java index cc20cc55c9..9030c20eea 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UnionTypeDefTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UnionTypeDefTest.java @@ -55,6 +55,8 @@ public class UnionTypeDefTest { case "stringRefValue": assertEquals(Types.STRING, generatedProperty.getReturnType()); break; + default: + // ignore } } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UsesTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UsesTest.java index e6b1ac9676..cc11015970 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UsesTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/UsesTest.java @@ -401,22 +401,22 @@ public class UsesTest { } } - 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()); @@ -425,7 +425,7 @@ public class UsesTest { 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()); diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/YangTextTemplateTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/YangTextTemplateTest.java index facdb2a8ec..d499cea1ea 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/YangTextTemplateTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/YangTextTemplateTest.java @@ -7,21 +7,24 @@ */ 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 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 diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtilsTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtilsTest.java index 7590bad700..9f3a17bc6d 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtilsTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtilsTest.java @@ -10,6 +10,8 @@ package org.opendaylight.mdsal.binding.generator.util; 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; @@ -94,22 +96,21 @@ public class YangSchemaUtilsTest { 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)); @@ -117,19 +118,19 @@ public class YangSchemaUtilsTest { 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 constructor = YangSchemaUtils.class.getDeclaredConstructor(); constructor.setAccessible(true); try { constructor.newInstance(); + fail(); } catch (InvocationTargetException e) { - throw e.getCause(); + assertTrue(e.getCause() instanceof UnsupportedOperationException); } } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySortTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySortTest.java index 748f873ea2..70a0776442 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySortTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySortTest.java @@ -28,8 +28,9 @@ public class GroupingDefinitionDependencySortTest { @Test public void testSortMethod() { - GroupingDefinitionDependencySort groupingDefinitionDependencySort = new GroupingDefinitionDependencySort(); - List unsortedGroupingDefs = new ArrayList<>(); + final GroupingDefinitionDependencySort groupingDefinitionDependencySort = + new GroupingDefinitionDependencySort(); + final List unsortedGroupingDefs = new ArrayList<>(); GroupingDefinition grp1 = mock(GroupingDefinition.class); doReturn(SchemaPath.create(false, QName.create("", "Cont1"), QName.create("", "Cont2"))).when(grp1).getPath(); diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullToStringInXpath.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullToStringInXpath.java index 238b350879..105b804dd1 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullToStringInXpath.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullToStringInXpath.java @@ -18,12 +18,9 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; 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 diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullXpath.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullXpath.java index 2fb962d610..83cbabec35 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullXpath.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/LeafrefTypeWithNullXpath.java @@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; 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> */ diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedTypeTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedTypeTest.java index 5c6e29f8e8..4dca2438c3 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedTypeTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/NodeWrappedTypeTest.java @@ -12,16 +12,15 @@ import static org.junit.Assert.assertFalse; 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)); diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderImplTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderImplTest.java index 0a7a397f54..ac4a0a5a16 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderImplTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderImplTest.java @@ -188,8 +188,8 @@ public class TypeProviderImplTest { 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 @@ -206,8 +206,7 @@ public class TypeProviderImplTest { 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()); } } diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderModel.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderModel.java index 3c273db932..be53d691fc 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderModel.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderModel.java @@ -11,13 +11,15 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; 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"); diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderTest.java index 00e5d60e57..1a0c80993b 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderTest.java @@ -51,10 +51,9 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; 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) @@ -233,9 +232,7 @@ public class TypeProviderTest { 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() { @@ -621,7 +618,8 @@ public class TypeProviderTest { 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); @@ -735,137 +733,137 @@ public class TypeProviderTest { 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"); @@ -876,15 +874,15 @@ public class TypeProviderTest { 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); @@ -894,35 +892,34 @@ public class TypeProviderTest { 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); } } -- 2.36.6