From: Robert Varga Date: Sat, 27 Feb 2016 13:00:41 +0000 (+0100) Subject: Remove dependencies on Module.getModuleSourcePath() X-Git-Tag: release/boron~172 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=fb99e6d628fb1fdf5e7339914b77f6e2ac62c9eb;hp=8e1f4badd0511e63ef4603bfe019c18e1ebc0a6a;p=mdsal.git Remove dependencies on Module.getModuleSourcePath() The source path is not something that can be expressed, as we may not even have the YANG sources for a particular model. Do not use it. Change-Id: I6c193edb7bae4d7dfd83e576c9618196aa06b4cf Signed-off-by: Robert Varga --- diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java index a3eb8cd50a..9caae2f318 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java @@ -27,7 +27,6 @@ import static org.opendaylight.yangtools.binding.generator.util.Types.typeForCla import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule; - import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -483,7 +482,7 @@ public class BindingGeneratorImpl implements BindingGenerator { final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule()); final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module, "Service"); interfaceBuilder.addImplementsType(Types.typeForClass(RpcService.class)); - interfaceBuilder.setDescription(createDescription(rpcDefinitions, module.getName(), module.getModuleSourcePath())); + interfaceBuilder.setDescription(createDescription(rpcDefinitions, module.getName())); for (final RpcDefinition rpc : rpcDefinitions) { if (rpc != null) { @@ -577,7 +576,7 @@ public class BindingGeneratorImpl implements BindingGenerator { .setComment(encodeAngleBrackets(notification.getDescription())).setReturnType(Types.VOID); } } - listenerInterface.setDescription(createDescription(notifications, module.getName(), module.getModuleSourcePath())); + listenerInterface.setDescription(createDescription(notifications, module.getName())); genCtx.get(module).addTopLevelNodeType(listenerInterface); } @@ -1447,7 +1446,7 @@ public class BindingGeneratorImpl implements BindingGenerator { return returnType; } - private static TypeDefinition getBaseOrDeclaredType(TypeDefinition typeDef) { + private static TypeDefinition getBaseOrDeclaredType(final TypeDefinition typeDef) { if (typeDef instanceof ExtendedType) { // Legacy behaviour returning ExtendedType is enough return typeDef; @@ -2091,7 +2090,7 @@ public class BindingGeneratorImpl implements BindingGenerator { return list == null || list.isEmpty(); } - private String createDescription(final Set schemaNodes, final String moduleName, final String moduleSourcePath) { + private String createDescription(final Set schemaNodes, final String moduleName) { final StringBuilder sb = new StringBuilder(); if (!isNullOrEmpty(schemaNodes)) { @@ -2104,10 +2103,6 @@ public class BindingGeneratorImpl implements BindingGenerator { } } sb.append(NEW_LINE); - sb.append("
(Source path: "); - sb.append(moduleSourcePath); - sb.append("):"); - sb.append(NEW_LINE); if (verboseClassComments) { sb.append("
");
@@ -2146,10 +2141,6 @@ public class BindingGeneratorImpl implements BindingGenerator {
             sb.append(module.getName());
             sb.append("");
             sb.append(NEW_LINE);
-            sb.append("
(Source path: "); - sb.append(module.getModuleSourcePath()); - sb.append("):"); - sb.append(NEW_LINE); sb.append("
");
             sb.append(NEW_LINE);
             sb.append(encodeAngleBrackets(YangTemplate.generateYangSnipet(schemaNode)));
@@ -2208,10 +2199,6 @@ public class BindingGeneratorImpl implements BindingGenerator {
             sb.append(module.getName());
             sb.append("");
             sb.append(NEW_LINE);
-            sb.append("
Source path: "); - sb.append(module.getModuleSourcePath()); - sb.append("):"); - sb.append(NEW_LINE); sb.append("
");
             sb.append(NEW_LINE);
             sb.append(encodeAngleBrackets(YangTemplate.generateYangSnipet(module)));
@@ -2261,7 +2248,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return ret.isEmpty() ? "" : ret;
     }
 
-    private void annotateDeprecatedIfNecessary(Status status, GeneratedTypeBuilder builder) {
+    private static void annotateDeprecatedIfNecessary(final Status status, final GeneratedTypeBuilder builder) {
         if (status == Status.DEPRECATED) {
             builder.addAnnotation("", "Deprecated");
         }
diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
index 80571e4b6a..7b718e57fd 100644
--- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
+++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
@@ -11,7 +11,6 @@ import static org.opendaylight.yangtools.binding.generator.util.BindingGenerator
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
-
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
@@ -493,9 +492,8 @@ public final class TypeProviderImpl implements TypeProvider {
                 } else {
                     dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module, parentNode, xpath);
                 }
-                Preconditions.checkArgument(dataNode != null, "Failed to find leafref target: %s in module %s (%s) at %s",
-                        strXPath, this.getParentModule(parentNode).getName(),
-                        parentNode.getQName().getModule(), this.getParentModule(parentNode).getModuleSourcePath());
+                Preconditions.checkArgument(dataNode != null, "Failed to find leafref target: %s in module %s (%s)",
+                        strXPath, this.getParentModule(parentNode).getName(), parentNode.getQName().getModule());
 
                 if (leafContainsEnumDefinition(dataNode)) {
                     returnType = referencedTypes.get(dataNode.getPath());
@@ -508,9 +506,8 @@ public final class TypeProviderImpl implements TypeProvider {
                 returnType = Types.typeForClass(Object.class);
             }
         }
-        Preconditions.checkArgument(returnType != null, "Failed to find leafref target: %s in module %s (%s) at %s",
-                strXPath, this.getParentModule(parentNode).getName(), parentNode.getQName().getModule(), this
-                        .getParentModule(parentNode).getModuleSourcePath());
+        Preconditions.checkArgument(returnType != null, "Failed to find leafref target: %s in module %s (%s)",
+                strXPath, this.getParentModule(parentNode).getName(), parentNode.getQName().getModule(), this);
         return returnType;
     }
 
@@ -1545,12 +1542,7 @@ public final class TypeProviderImpl implements TypeProvider {
         return sb.toString();
     }
 
-    private static final Comparator BIT_NAME_COMPARATOR = new Comparator() {
-        @Override
-        public int compare(final Bit o1, final Bit o2) {
-            return o1.getName().compareTo(o2.getName());
-        }
-    };
+    private static final Comparator BIT_NAME_COMPARATOR = (o1, o2) -> o1.getName().compareTo(o2.getName());
 
     private static String bitsToDef(final BitsTypeDefinition type, final String className, final String defaultValue, final boolean isExt) {
         List bits = new ArrayList<>(type.getBits());
@@ -1631,12 +1623,7 @@ public final class TypeProviderImpl implements TypeProvider {
                 }
                 if (module == null) {
                     List modulesList = new ArrayList<>(modules);
-                    Collections.sort(modulesList, new Comparator() {
-                        @Override
-                        public int compare(final Module o1, final Module o2) {
-                            return o1.getRevision().compareTo(o2.getRevision());
-                        }
-                    });
+                    Collections.sort(modulesList, (o1, o2) -> o1.getRevision().compareTo(o2.getRevision()));
                     module = modulesList.get(0);
                 }
             } else {
diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java
index e4fe8f4ca6..f286b3ebbc 100644
--- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java
+++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import com.google.common.io.ByteSource;
 import java.io.File;
 import java.io.IOException;
@@ -258,7 +257,7 @@ public class GeneratedTypesLeafrefTest {
             bindingGen.generateTypes(context);
             fail("Expected IllegalArgumentException caused by invalid leafref path");
         } catch (IllegalArgumentException e) {
-            String expected = "Failed to find leafref target: ../id in module foo (QNameModule{ns=urn:yang.foo, rev=2014-03-10}) at";
+            String expected = "Failed to find leafref target: ../id in module foo (QNameModule{ns=urn:yang.foo, rev=2014-03-10})";
             assertTrue(e.getMessage().startsWith(expected));
         }
     }