Remove dependencies on Module.getModuleSourcePath() 09/35509/2
authorRobert Varga <rovarga@cisco.com>
Sat, 27 Feb 2016 13:00:41 +0000 (14:00 +0100)
committerRobert Varga <rovarga@cisco.com>
Tue, 1 Mar 2016 12:55:22 +0000 (13:55 +0100)
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 <rovarga@cisco.com>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java

index a3eb8cd50a7cadd895518846fecc5be9963af5ff..9caae2f3180040c6903676d66f5f74be31ab34cf 100644 (file)
@@ -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<? extends SchemaNode> schemaNodes, final String moduleName, final String moduleSourcePath) {
+    private String createDescription(final Set<? extends SchemaNode> 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("<br>(Source path: <i>");
-        sb.append(moduleSourcePath);
-        sb.append("</i>):");
-        sb.append(NEW_LINE);
 
         if (verboseClassComments) {
             sb.append("<pre>");
@@ -2146,10 +2141,6 @@ public class BindingGeneratorImpl implements BindingGenerator {
             sb.append(module.getName());
             sb.append("</b>");
             sb.append(NEW_LINE);
-            sb.append("<br>(Source path: <i>");
-            sb.append(module.getModuleSourcePath());
-            sb.append("</i>):");
-            sb.append(NEW_LINE);
             sb.append("<pre>");
             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("</b>");
             sb.append(NEW_LINE);
-            sb.append("<br>Source path: <i>");
-            sb.append(module.getModuleSourcePath());
-            sb.append("</i>):");
-            sb.append(NEW_LINE);
             sb.append("<pre>");
             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");
         }
index 80571e4b6a7b60e4330367b7201edf3bd8032d3a..7b718e57fd1e3abef8e23f8f550f9b6069686012 100644 (file)
@@ -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> BIT_NAME_COMPARATOR = new Comparator<Bit>() {
-        @Override
-        public int compare(final Bit o1, final Bit o2) {
-            return o1.getName().compareTo(o2.getName());
-        }
-    };
+    private static final Comparator<Bit> 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<Bit> bits = new ArrayList<>(type.getBits());
@@ -1631,12 +1623,7 @@ public final class TypeProviderImpl implements TypeProvider {
                 }
                 if (module == null) {
                     List<Module> modulesList = new ArrayList<>(modules);
-                    Collections.sort(modulesList, new Comparator<Module>() {
-                        @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 {
index e4fe8f4ca63c5eb297897b905080e0810239c6d8..f286b3ebbcbab3c6f3632ee88be11950738a32bc 100644 (file)
@@ -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));
         }
     }