Fix warnings in mdsal-binding-generator-impl 29/57029/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 14 May 2017 22:11:19 +0000 (00:11 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 15 May 2017 15:27:56 +0000 (15:27 +0000)
- xtend comparison to null
- unnecessary boxing
- unneeded imports
- raw types

Change-Id: Id2d987fdf0cc3b94c78250018bc06b77ab0726f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/YangTemplate.xtend
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/SourceCodeGeneratorFactory.java
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/GroupingDefinitionDependencySort.java
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/TypeProviderImpl.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/CodecTypeUtilsTest.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/GeneratedTypesTest.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/util/SourceCodeGeneratorFactoryTest.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtilsTest.java

index 33bd1b18a7b85d69e45111a738a2c4689f439e93..d8fb01e041d66bb13ba5e8a011928539177f5454 100644 (file)
@@ -549,9 +549,9 @@ public class BindingGeneratorImpl implements BindingGenerator {
         genCtx.get(module).addTopLevelNodeType(interfaceBuilder);
     }
 
-    private static boolean isExplicitStatement(ContainerSchemaNode node) {
+    private static boolean isExplicitStatement(final ContainerSchemaNode node) {
         return node instanceof EffectiveStatement
-                && ((EffectiveStatement) node).getDeclared().getStatementSource() == StatementSource.DECLARATION;
+                && ((EffectiveStatement<?, ?>) node).getDeclared().getStatementSource() == StatementSource.DECLARATION;
     }
 
     /**
@@ -723,8 +723,6 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            GroupingDefinition which contains data about grouping
      * @param module
      *            current module
-     * @return GeneratedType which is generated from grouping (object of type
-     *         <code>GroupingDefinition</code>)
      */
     private void groupingToGenType(final String basePackageName, final GroupingDefinition grouping, final Module module) {
         final String packageName = packageNameForGeneratedType(basePackageName, grouping.getPath());
@@ -943,17 +941,15 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 // The original node is required, but we have only the copy of
                 // the original node.
                 // Maybe this indicates a bug in Yang parser.
-                throw new IllegalStateException(
-                        "Failed to generate code for augment in "
-                                + parentUsesNode);
-            } else {
-                return resultDataSchemaNode;
+                throw new IllegalStateException("Failed to generate code for augment in " + parentUsesNode);
             }
-        } else {
-            throw new IllegalStateException(
-                    "Target node of uses-augment statement must be DataSchemaNode. Failed to generate code for augment in "
-                            + parentUsesNode);
+
+            return resultDataSchemaNode;
         }
+
+        throw new IllegalStateException(
+            "Target node of uses-augment statement must be DataSchemaNode. Failed to generate code for augment in "
+                    + parentUsesNode);
     }
 
     /**
@@ -1111,7 +1107,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
     private GeneratedTypeBuilder augSchemaNodeToMethods(final Module module, final String basePackageName,
             final GeneratedTypeBuilder typeBuilder, final GeneratedTypeBuilder childOf,
             final Iterable<DataSchemaNode> schemaNodes) {
-        if ((schemaNodes != null) && (typeBuilder != null)) {
+        if (schemaNodes != null && typeBuilder != null) {
             for (final DataSchemaNode schemaNode : schemaNodes) {
                 if (!schemaNode.isAugmenting()) {
                     addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder, childOf, module);
@@ -1218,7 +1214,6 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            type which represents superior <i>case</i>
      * @param choiceNode
      *            choice case node which is mapped to generated type
-     * @return list of generated types for <code>caseNodes</code>.
      * @throws IllegalArgumentException
      *             <ul>
      *             <li>if <code>basePackageName</code> equals null</li>
@@ -1305,8 +1300,6 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @param augmentedNodes
      *            set of choice case nodes for which is checked if are/aren't
      *            added to choice through augmentation
-     * @return list of generated types which represents augmented cases of
-     *         choice <code>refChoiceType</code>
      * @throws IllegalArgumentException
      *             <ul>
      *             <li>if <code>basePackageName</code> is null</li>
@@ -1474,7 +1467,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
     private static TypeDefinition<?> getBaseOrDeclaredType(final TypeDefinition<?> typeDef) {
         // Returns DerivedType in case of new parser.
         final TypeDefinition<?> baseType = typeDef.getBaseType();
-        return (baseType != null && baseType.getBaseType() != null) ? baseType : typeDef;
+        return baseType != null && baseType.getBaseType() != null ? baseType : typeDef;
     }
 
     private void processContextRefExtension(final LeafSchemaNode leaf, final MethodSignatureBuilder getter,
@@ -1996,7 +1989,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
      */
     private static GeneratedTOBuilder resolveListKeyTOBuilder(final String packageName, final ListSchemaNode list) {
         GeneratedTOBuilder genTOBuilder = null;
-        if ((list.getKeyDefinition() != null) && (!list.getKeyDefinition().isEmpty())) {
+        if (list.getKeyDefinition() != null && !list.getKeyDefinition().isEmpty()) {
             final String listName = list.getQName().getLocalName() + "Key";
             final String genTOName = BindingMapping.getClassName(listName);
             genTOBuilder = new GeneratedTOBuilderImpl(packageName, genTOName);
@@ -2032,7 +2025,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         final String packageName = typeBuilder.getFullyQualifiedName();
         if (typeDef instanceof UnionTypeDefinition) {
             final List<GeneratedTOBuilder> types = ((TypeProviderImpl) typeProvider)
-                    .provideGeneratedTOBuildersForUnionTypeDef(packageName, ((UnionTypeDefinition) typeDef),
+                    .provideGeneratedTOBuildersForUnionTypeDef(packageName, (UnionTypeDefinition) typeDef,
                             classNameFromLeaf, leaf);
             genTOBuilders.addAll(types);
 
@@ -2052,7 +2045,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             resultTOBuilder.addToStringProperty(genPropBuilder);
 
         } else if (typeDef instanceof BitsTypeDefinition) {
-            genTOBuilders.add((((TypeProviderImpl) typeProvider)).provideGeneratedTOBuilderForBitsTypeDefinition(
+            genTOBuilders.add(((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForBitsTypeDefinition(
                     packageName, typeDef, classNameFromLeaf, parentModule.getName()));
         }
         if (!genTOBuilders.isEmpty()) {
index 7c9ac94f6afe5694854235f5798d2ceff9710a00..93a01f41e576e3b64d3a79704630b0a6ffa79f09 100644 (file)
@@ -47,7 +47,7 @@ class YangTemplate {
     private static val SKIP = Boolean.getBoolean(SKIP_PROPERTY_NAME);
 
     def static String generateYangSnipet(SchemaNode schemaNode) {
-        if (schemaNode == null)
+        if (schemaNode === null)
             return ''
         if (SKIP)
             return '''(Empty due to «SKIP_PROPERTY_NAME» property = true)'''
@@ -115,7 +115,7 @@ class YangTemplate {
 
         '''
             «FOR moduleImport : moduleImports SEPARATOR "\n"»
-                «IF moduleImport != null && !moduleImport.moduleName.nullOrEmpty»
+                «IF moduleImport !== null && !moduleImport.moduleName.nullOrEmpty»
                 import «moduleImport.moduleName» { prefix "«moduleImport.prefix»"; }
                 «ENDIF»
             «ENDFOR»
@@ -144,7 +144,7 @@ class YangTemplate {
                 «IF !module.imports.nullOrEmpty»
                 «writeModuleImports(module.imports)»
                 «ENDIF»
-                «IF module.revision != null»
+                «IF module.revision !== null»
                 «writeRevision(module.revision, module.description)»
                 «ENDIF»
                 «IF !module.childNodes.nullOrEmpty»
@@ -198,7 +198,7 @@ class YangTemplate {
     def private static writeRPCs(Set<RpcDefinition> rpcDefs) {
         '''
             «FOR rpc : rpcDefs»
-                «IF rpc != null»
+                «IF rpc !== null»
                 «writeRPC(rpc)»
                 «ENDIF»
             «ENDFOR»
@@ -215,10 +215,10 @@ class YangTemplate {
                 «IF !rpc.groupings.nullOrEmpty»
                     «writeGroupingDefs(rpc.groupings)»
                 «ENDIF»
-                «IF rpc.input != null»
+                «IF rpc.input !== null»
                     «writeRpcInput(rpc.input)»
                 «ENDIF»
-                «IF rpc.output != null»
+                «IF rpc.output !== null»
                     «writeRpcOutput(rpc.output)»
                 «ENDIF»
                 «IF !rpc.reference.nullOrEmpty»
@@ -233,7 +233,7 @@ class YangTemplate {
     }
 
     def private static writeRpcInput(ContainerSchemaNode input) {
-        if(input == null)
+        if (input === null)
             return ''
 
         '''
@@ -247,7 +247,7 @@ class YangTemplate {
     }
 
     def private static writeRpcOutput(ContainerSchemaNode output) {
-        if(output == null)
+        if (output === null)
             return ''
 
         '''
@@ -262,7 +262,7 @@ class YangTemplate {
     def private static writeNotifications(Set<NotificationDefinition> notifications) {
         '''
             «FOR notification : notifications»
-                «IF notification != null»
+                «IF notification !== null»
                 «writeNotification(notification)»
                 «ENDIF»
             «ENDFOR»
@@ -316,13 +316,13 @@ class YangTemplate {
     }
 
     def private static writeUsesNodes(Set<UsesNode> usesNodes) {
-        if (usesNodes == null) {
+        if (usesNodes === null) {
             return ''
         }
 
         '''
             «FOR usesNode : usesNodes»
-                «IF usesNode != null»
+                «IF usesNode !== null»
                 «writeUsesNode(usesNode)»
                 «ENDIF»
             «ENDFOR»
@@ -381,11 +381,11 @@ class YangTemplate {
     }
 
     def private static writeIdentity(IdentitySchemaNode identity) {
-        if (identity == null)
+        if (identity === null)
             return ''
         '''
             identity «identity.QName.localName» {
-                «IF identity.baseIdentity != null»
+                «IF identity.baseIdentity !== null»
                 base "()«identity.baseIdentity»";
                 «ENDIF»
                 «IF !identity.description.nullOrEmpty»
@@ -396,7 +396,7 @@ class YangTemplate {
                 reference
                     "«identity.reference»";
                 «ENDIF»
-                «IF identity.status != null»
+                «IF identity.status !== null»
                 status «identity.status»;
                 «ENDIF»
             }
@@ -406,7 +406,7 @@ class YangTemplate {
     def private static writeFeatures(Set<FeatureDefinition> features) {
         '''
             «FOR feature : features»
-                «IF feature != null»
+                «IF feature !== null»
                 «writeFeature(feature)»
                 «ENDIF»
             «ENDFOR»
@@ -424,7 +424,7 @@ class YangTemplate {
                 reference
                     "«featureDef.reference»";
                 «ENDIF»
-                «IF featureDef.status != null»
+                «IF featureDef.status !== null»
                 status «featureDef.status»;
                 «ENDIF»
             }
@@ -434,7 +434,7 @@ class YangTemplate {
     def private static writeExtensions(List<ExtensionDefinition> extensions) {
         '''
             «FOR anExtension : extensions»
-                «IF anExtension != null»
+                «IF anExtension !== null»
                 «writeExtension(anExtension)»
                 «ENDIF»
             «ENDFOR»
@@ -455,7 +455,7 @@ class YangTemplate {
                 reference
                     "«extensionDef.reference»";
                 «ENDIF»
-                «IF extensionDef.status != null»
+                «IF extensionDef.status !== null»
                 status «extensionDef.status»;
                 «ENDIF»
             }
@@ -465,7 +465,7 @@ class YangTemplate {
     def private static writeDeviations(Set<Deviation> deviations) {
         '''
             «FOR deviation : deviations»
-                «IF deviation != null»
+                «IF deviation !== null»
                 «writeDeviation(deviation)»
                 «ENDIF»
             «ENDFOR»
@@ -480,7 +480,7 @@ class YangTemplate {
                         "«deviation.reference»";
                 «ENDIF»
                 «FOR dev : deviation.deviates»
-                    «IF dev != null && dev.deviateType != null»
+                    «IF dev !== null && dev.deviateType !== null»
                         deviation «dev.deviateType.name»;
                     «ENDIF»
                 «ENDFOR»
@@ -491,7 +491,7 @@ class YangTemplate {
     def private static writeAugments(Set<AugmentationSchema> augments) {
         '''
             «FOR augment : augments»
-                «IF augment != null»
+                «IF augment !== null»
                 «writeAugment(augment)»
                 «ENDIF»
             «ENDFOR»
@@ -509,7 +509,7 @@ class YangTemplate {
     def private static CharSequence writeGroupingDefs(Set<GroupingDefinition> groupingDefs) {
         '''
             «FOR groupingDef : groupingDefs»
-                «IF groupingDef != null»
+                «IF groupingDef !== null»
                 «writeGroupingDef(groupingDef)»
                 «ENDIF»
             «ENDFOR»
@@ -519,7 +519,7 @@ class YangTemplate {
     def private static writeAugment(AugmentationSchema augment) {
         '''
             augment «YangTextTemplate.formatToAugmentPath(augment.targetPath.pathFromRoot)» {
-                «IF augment.whenCondition != null && !augment.whenCondition.toString.nullOrEmpty»
+                «IF augment.whenCondition !== null && !augment.whenCondition.toString.nullOrEmpty»
                 when "«augment.whenCondition.toString»";
                 «ENDIF»
                 «IF !augment.description.nullOrEmpty»
@@ -530,7 +530,7 @@ class YangTemplate {
                 reference
                     "«augment.reference»";
                 «ENDIF»
-                «IF augment.status != null»
+                «IF augment.status !== null»
                 status «augment.status»;
                 «ENDIF»
                 «IF !augment.childNodes.nullOrEmpty»
index 693edec96f68b26b9607062bad67a6be988e7e22..e4b26e9095c535d34cb6919228c64e7f8d9fee93 100644 (file)
@@ -29,10 +29,9 @@ public class SourceCodeGeneratorFactory {
      * @param generatedSourceDir the directory in which to put generated source files. If null,
      *     a default is used (see DefaultSourceCodeGenerator).
      */
-    public SourceCodeGenerator getInstance(String generatedSourceDir) {
-
-        boolean generateSource = Boolean.valueOf(System.getProperty( GENERATE_CODEC_SOURCE_PROP, "false"));
-        if(generateSource) {
+    public SourceCodeGenerator getInstance(final String generatedSourceDir) {
+        boolean generateSource = Boolean.getBoolean(GENERATE_CODEC_SOURCE_PROP);
+        if (generateSource) {
             return new DefaultSourceCodeGenerator(generatedSourceDir);
         }
 
index dd2ba1b8a70fd662a16c888ce81b58c9ffe31ece..e3e90dfbc2c9d3deeae94c111542c28056cc9f00 100644 (file)
@@ -61,12 +61,12 @@ public class GroupingDefinitionDependencySort {
             throw new IllegalArgumentException("Set of Type Definitions " + "cannot be NULL!");
         }
 
-        final List<GroupingDefinition> resultGroupingDefinitions = new ArrayList<GroupingDefinition>();
+        final List<GroupingDefinition> resultGroupingDefinitions = new ArrayList<>();
         final Set<Node> unsorted = groupingDefinitionsToNodes(groupingDefinitions);
         final List<Node> sortedNodes = TopologicalSort.sort(unsorted);
         for (Node node : sortedNodes) {
             NodeWrappedType nodeWrappedType = (NodeWrappedType) node;
-            resultGroupingDefinitions.add((GroupingDefinition) (nodeWrappedType.getWrappedType()));
+            resultGroupingDefinitions.add((GroupingDefinition) nodeWrappedType.getWrappedType());
         }
         return resultGroupingDefinitions;
 
index fa4343a7d0db3696bd64462aa5c7cee247862c02..88a911cd6bc82b3e7efb9102065a21ace43fc9f3 100644 (file)
@@ -233,7 +233,7 @@ public final class TypeProviderImpl implements TypeProvider {
             String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, typeDefinition.getPath());
             String genTOName = BindingMapping.getClassName(typedefName);
             String name = packageName + "." + genTOName;
-            if (!(returnType.getFullyQualifiedName().equals(name))) {
+            if (!returnType.getFullyQualifiedName().equals(name)) {
                 returnType = shadedTOWithRestrictions(gto, r);
             }
         }
@@ -299,7 +299,7 @@ public final class TypeProviderImpl implements TypeProvider {
         } else {
             leafRefValueNode = SchemaContextUtil.findDataSchemaNode(schemaContext, parentModule, leafRefStrippedXPath);
         }
-        return (leafRefValueNode != null) ? leafRefValueNode.equals(parentNode) : false;
+        return leafRefValueNode != null ? leafRefValueNode.equals(parentNode) : false;
     }
 
     /**
@@ -735,7 +735,7 @@ public final class TypeProviderImpl implements TypeProvider {
     private Type typedefToGeneratedType(final String basePackageName, final Module module, final TypeDefinition<?> typedef) {
         final String moduleName = module.getName();
         final Date moduleRevision = module.getRevision();
-        if ((basePackageName != null) && (moduleName != null) && (typedef != null) && (typedef.getQName() != null)) {
+        if (basePackageName != null && moduleName != null && typedef != null && typedef.getQName() != null) {
             final String typedefName = typedef.getQName().getLocalName();
             final TypeDefinition<?> innerTypeDefinition = typedef.getBaseType();
             if (!(innerTypeDefinition instanceof LeafrefTypeDefinition)
@@ -909,7 +909,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
         generatedTOBuilders.add(unionGenTOBuilder);
         unionGenTOBuilder.setIsUnion(true);
-        final List<String> regularExpressions = new ArrayList<String>();
+        final List<String> regularExpressions = new ArrayList<>();
         for (final TypeDefinition<?> unionType : unionTypes) {
             final String unionTypeName = unionType.getQName().getLocalName();
             if (unionType.getBaseType() != null) {
@@ -1095,7 +1095,7 @@ public final class TypeProviderImpl implements TypeProvider {
         final String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, typedef.getPath());
         final String typeDefTOName = typedef.getQName().getLocalName();
 
-        if ((packageName != null) && (typeDefTOName != null)) {
+        if (packageName != null && typeDefTOName != null) {
             final String genTOName = BindingMapping.getClassName(typeDefTOName);
             final GeneratedTOBuilderImpl newType = new GeneratedTOBuilderImpl(packageName, genTOName);
             final String typedefDescription = encodeAngleBrackets(typedef.getDescription());
@@ -1333,10 +1333,10 @@ public final class TypeProviderImpl implements TypeProvider {
 
         Map<Integer, List<TypeDefinition<?>>> typeDefinitionsDepths = new TreeMap<>();
         for (TypeDefinition<?> unsortedTypeDefinition : unsortedTypeDefinitions) {
-            final int depth = getTypeDefinitionDepth(unsortedTypeDefinition);
+            final Integer depth = getTypeDefinitionDepth(unsortedTypeDefinition);
             List<TypeDefinition<?>> typeDefinitionsConcreteDepth = typeDefinitionsDepths.get(depth);
             if (typeDefinitionsConcreteDepth == null) {
-                typeDefinitionsConcreteDepth = new ArrayList<TypeDefinition<?>>();
+                typeDefinitionsConcreteDepth = new ArrayList<>();
                 typeDefinitionsDepths.put(depth, typeDefinitionsConcreteDepth);
             }
             typeDefinitionsConcreteDepth.add(unsortedTypeDefinition);
@@ -1399,11 +1399,11 @@ public final class TypeProviderImpl implements TypeProvider {
     private static String provideAvailableNameForGenTOBuilder(final String name) {
         Matcher mtch = NUMBERS_PATTERN.matcher(name);
         if (mtch.find()) {
-            final int newSuffix = Integer.valueOf(name.substring(mtch.start())) + 1;
+            final int newSuffix = Integer.parseInt(name.substring(mtch.start())) + 1;
             return name.substring(0, mtch.start()) + newSuffix;
-        } else {
-            return name + 1;
         }
+
+        return name + 1;
     }
 
     public static void addUnitsToGenTO(final GeneratedTOBuilder to, final String units) {
@@ -1438,7 +1438,7 @@ public final class TypeProviderImpl implements TypeProvider {
             Module parent = getParentModule(node);
             Iterator<QName> path = node.getPath().getPathFromRoot().iterator();
             path.next();
-            if (!(path.hasNext())) {
+            if (!path.hasNext()) {
                 parentName = BindingMapping.getClassName(parent.getName()) + "Data";
                 String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule());
                 className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
@@ -1656,11 +1656,11 @@ public final class TypeProviderImpl implements TypeProvider {
         } else {
             Iterator<QName> path = node.getPath().getPathFromRoot().iterator();
             QName first = path.next();
-            if (!(path.hasNext())) {
+            if (!path.hasNext()) {
                 URI namespace = first.getNamespace();
                 Date revision = first.getRevision();
                 Module parent = schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
-                parentName = BindingMapping.getClassName((parent).getName()) + "Data";
+                parentName = BindingMapping.getClassName(parent.getName()) + "Data";
                 String basePackageName = BindingMapping.getRootPackageName(parent.getQNameModule());
                 className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
             } else {
@@ -1687,11 +1687,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     @Override
     public String getConstructorPropertyName(final SchemaNode node) {
-        if (node instanceof TypeDefinition<?>) {
-            return "value";
-        } else {
-            return "";
-        }
+        return node instanceof TypeDefinition<?> ? "value" : "";
     }
 
     @Override
index 58ecca4034d932f87e0d19176ac8af2756105f79..15f9904436f7899905c9d418abcffc8994f3275a 100644 (file)
@@ -12,7 +12,6 @@ import static org.mockito.Mockito.mock;
 
 import java.lang.reflect.Constructor;
 import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.impl.CodecTypeUtils;
 import org.opendaylight.yangtools.yang.binding.Identifiable;
 import org.opendaylight.yangtools.yang.binding.Identifier;
 
@@ -25,7 +24,7 @@ public class CodecTypeUtilsTest {
 
     @Test(expected = UnsupportedOperationException.class)
     public void privateConstructTest() throws Throwable {
-        final Constructor constructor = CodecTypeUtils.class.getDeclaredConstructor();
+        final Constructor<?> constructor = CodecTypeUtils.class.getDeclaredConstructor();
         constructor.setAccessible(true);
         try {
             constructor.newInstance();
index a2da175fd246ca48eb6161988a3600f477aba92b..b47b3dd1cb06bf71ffd7e3f85d3eca4807e2a3bb 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.mdsal.binding.generator.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
@@ -16,7 +17,6 @@ import java.net.URISyntaxException;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.generator.api.BindingGenerator;
-import org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl;
 import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
@@ -315,7 +315,7 @@ public class GeneratedTypesTest {
         assertEquals(1, listKeyClassPropertyCount);
         assertEquals("listKey", listKeyClassPropertyName);
         assertEquals("Byte", listKeyClassPropertyTypeName);
-        assertEquals(true, listKeyClassPropertyReadOnly);
+        assertTrue(listKeyClassPropertyReadOnly);
         assertEquals(1, hashMethodParameterCount);
         assertEquals("listKey", hashMethodParameterName);
         assertEquals("Byte", hashMethodParameterReturnTypeName);
index bd8ba9c118811144c7df7838edd59382235bee07..eb061a430443df27d283031e912ac22932074d3b 100644 (file)
@@ -26,10 +26,6 @@ import javassist.CtMethod;
 import javassist.bytecode.AccessFlag;
 import javassist.bytecode.ClassFile;
 import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.util.DefaultSourceCodeGenerator;
-import org.opendaylight.mdsal.binding.generator.util.NullSourceCodeGenerator;
-import org.opendaylight.mdsal.binding.generator.util.SourceCodeGenerator;
-import org.opendaylight.mdsal.binding.generator.util.SourceCodeGeneratorFactory;
 
 public class SourceCodeGeneratorFactoryTest {
 
@@ -84,7 +80,7 @@ public class SourceCodeGeneratorFactoryTest {
 
         generator = new DefaultSourceCodeGenerator(dir.getName());
         final CtClass ctClass = mock(CtClass.class, CALLS_REAL_METHODS);
-        doReturn(false).when(ctClass).isFrozen();
+        doReturn(Boolean.FALSE).when(ctClass).isFrozen();
         ctClass.setName("TestClass");
         final ClassPool classPool = mock(ClassPool.class);
         doReturn(ctClass).when(classPool).get((String) any());
@@ -92,12 +88,12 @@ public class SourceCodeGeneratorFactoryTest {
         doReturn(ctClass).when(ctClass).getSuperclass();
         doReturn(new CtClass[] {ctClass,ctClass}).when(ctClass).getInterfaces();
         doReturn(classPool).when(ctClass).getClassPool();
-        doReturn(false).when(ctClass).isArray();
-        doReturn(false).when(ctClass).isPrimitive();
+        doReturn(Boolean.FALSE).when(ctClass).isArray();
+        doReturn(Boolean.FALSE).when(ctClass).isPrimitive();
         doReturn(AccessFlag.toModifier(AccessFlag.PUBLIC)).when(ctClass).getModifiers();
         final ClassFile classFile = new ClassFile(false,"test", null);
         doReturn(classFile).when(ctClass).getClassFile2();
-        doReturn(false).when(ctClass).isFrozen();
+        doReturn(Boolean.FALSE).when(ctClass).isFrozen();
         doReturn("testClass").when(ctClass).getName();
         final CtField ctField = mock(CtField.class);
         doReturn(AccessFlag.toModifier(AccessFlag.PUBLIC)).when(ctField).getModifiers();
@@ -116,8 +112,10 @@ public class SourceCodeGeneratorFactoryTest {
         assertTrue(cleanup(dir));
     }
 
-    private boolean cleanup(File dir) {
-        if (!dir.exists()) return true;
+    private static boolean cleanup(final File dir) {
+        if (!dir.exists()) {
+            return true;
+        }
 
         stream(dir.listFiles()).forEach(File::delete);
         return dir.delete();
index 387060ad194888aa862e1cfd56e6fc9ae2594297..9fb1ffffb7b39c96d508e4598f67436292e53307 100644 (file)
@@ -25,7 +25,6 @@ import java.util.Date;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.mdsal.binding.generator.util.YangSchemaUtils;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
@@ -59,7 +58,7 @@ public class YangSchemaUtilsTest {
         final DataSchemaNode dataSchemaNode = mock(DataSchemaNode.class);
         doReturn(Q_NAME).when(UNKNOWN_SCHEMA_NODE).getNodeType();
         doReturn(ImmutableList.of(dataSchemaNode)).when(AUGMENTATION_SCHEMA).getChildNodes();
-        doReturn(false).when(dataSchemaNode).isAugmenting();
+        doReturn(Boolean.FALSE).when(dataSchemaNode).isAugmenting();
         doReturn(Q_NAME).when(dataSchemaNode).getQName();
         doReturn(ImmutableList.of(dataSchemaNode)).when(AUGMENTATION_SCHEMA).getChildNodes();
         assertEquals(Q_NAME, YangSchemaUtils.getAugmentationQName(AUGMENTATION_SCHEMA));
@@ -79,7 +78,7 @@ public class YangSchemaUtilsTest {
         final QName qName = QName.create(context.getModules().iterator().next().getNamespace(),
                 context.getModules().iterator().next().getRevision(), context.getModules().iterator().next().getName());
         assertNull(YangSchemaUtils.findTypeDefinition(context, SchemaPath.create(ImmutableList.of(qName), false)));
-        final List qNames = new ArrayList();
+        final List<QName> qNames = new ArrayList<>();
         context.getTypeDefinitions().forEach(typeDefinition -> qNames.add(typeDefinition.getQName()));
         assertNull(YangSchemaUtils.findTypeDefinition(context, SchemaPath.create(qNames, false)));
 
@@ -91,7 +90,7 @@ public class YangSchemaUtilsTest {
 
         final DataSchemaNode node = mock(DataSchemaNode.class);
         doReturn(node).when(container).getDataChildByName((QName) any());
-        final TypeDefinition typeDefinition = mock(TypeDefinition.class);
+        final TypeDefinition<?> typeDefinition = mock(TypeDefinition.class);
         doReturn(Q_NAME).when(typeDefinition).getQName();
         doReturn(ImmutableSet.of(typeDefinition)).when(container).getTypeDefinitions();
         assertEquals(typeDefinition,