Acquire first value manually in ClassTemplate 94/84394/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Sep 2019 12:40:35 +0000 (14:40 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 13 Sep 2019 14:24:07 +0000 (16:24 +0200)
xtend's get(0) extension ends up creating a temporary list
holding a copy of the (single) value. This is not entirely
efficient, as we can get the same result from plain iterator.

Change-Id: I0f4398a47cb771e8ab7a212a67c5e402d49ffbf2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 878c3a64f17c7771bb6fac0d42f8e9c1307d6096)

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

index 07795a5f03a4691e2283c92a31df6d56c7da3354..9aab6330838e2922d8c938bbf3636b2b54e32ebd 100644 (file)
@@ -441,7 +441,7 @@ class ClassTemplate extends BaseTemplate {
                     FOR v : cValue.keySet SEPARATOR ", "»"«v.escapeJava»"«ENDFOR»);
                     «IF cValue.size == 1»
                         private static final «Pattern.importedName» «Constants.MEMBER_PATTERN_LIST» = «Pattern.importedName».compile(«TypeConstants.PATTERN_CONSTANT_NAME».get(0));
-                        private static final String «Constants.MEMBER_REGEX_LIST» = "«cValue.values.get(0).escapeJava»";
+                        private static final String «Constants.MEMBER_REGEX_LIST» = "«cValue.values.iterator.next.escapeJava»";
                     «ELSE»
                         private static final «Pattern.importedName»[] «Constants.MEMBER_PATTERN_LIST» = «CodeHelpers.importedName».compilePatterns(«TypeConstants.PATTERN_CONSTANT_NAME»);
                         private static final String[] «Constants.MEMBER_REGEX_LIST» = { «