Fix YangModuleInfoTemplate 76/72376/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 28 May 2018 17:29:06 +0000 (19:29 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 28 May 2018 19:20:52 +0000 (21:20 +0200)
Optional is not comparable, hence we need to pass an explicit
Comparator to the TreeMap.

JIRA: MDSAL-344
Change-Id: I79e8000c85ed74d3f14e77da156038f3c781aa59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit aa92942e2b516b0c14c7bbd5048c398c3ccc9ce0)

binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/YangModuleInfoTemplate.xtend

index 912434a76f1047b93de5d1adbde16f63d5a732e7..a39d755f6c70153929355f0231af05aa0e384aa6 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableSet
 import java.io.IOException
 import java.io.InputStream
 import java.util.Collections
+import java.util.Comparator
 import java.util.HashSet
 import java.util.LinkedHashMap
 import java.util.Map
@@ -36,6 +37,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext
 import org.opendaylight.yangtools.yang.common.Revision
 
 class YangModuleInfoTemplate {
+    static val Comparator<Optional<Revision>> REVISION_COMPARATOR =
+        [ Optional<Revision> first, Optional<Revision> second | Revision.compare(first, second) ]
 
     val Module module
     val SchemaContext ctx
@@ -113,7 +116,7 @@ class YangModuleInfoTemplate {
                     «val rev = imp.revision»
                     «IF !rev.present»
                         «val Set<Module> modules = ctx.modules»
-                        «val TreeMap<Optional<Revision>, Module> sorted = new TreeMap()»
+                        «val TreeMap<Optional<Revision>, Module> sorted = new TreeMap(REVISION_COMPARATOR
                         «FOR module : modules»
                             «IF module.name.equals(name)»
                                 «sorted.put(module.revision, module)»