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>
import com.google.common.base.Preconditions
import com.google.common.collect.ImmutableSet
import java.util.Collections
import com.google.common.base.Preconditions
import com.google.common.collect.ImmutableSet
import java.util.Collections
+import java.util.Comparator
import java.util.HashSet
import java.util.LinkedHashMap
import java.util.Map
import java.util.HashSet
import java.util.LinkedHashMap
import java.util.Map
* QNAME constants.
*/
class YangModuleInfoTemplate {
* QNAME constants.
*/
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
val Module module
val SchemaContext ctx
«val rev = imp.revision»
«IF !rev.present»
«val Set<Module> modules = ctx.modules»
«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)»
«FOR module : modules»
«IF module.name.equals(name)»
«sorted.put(module.revision, module)»