}
private String getGetterName(final QName qName, TypeDefinition<?> typeDef) {
- final String suffix = BindingMapping.getClassName(qName);
-
+ final String suffix = BindingMapping.getGetterSuffix(qName);
while (typeDef.getBaseType() != null) {
typeDef = typeDef.getBaseType();
}
import static org.opendaylight.yangtools.sal.java.api.generator.stmt.parser.retest.CompilationTestUtils.cleanUp;
import static org.opendaylight.yangtools.sal.java.api.generator.stmt.parser.retest.CompilationTestUtils.getSourceFiles;
import static org.opendaylight.yangtools.sal.java.api.generator.stmt.parser.retest.CompilationTestUtils.testCompilation;
+
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
cleanUp(sourcesOutputDir, compiledOutputDir);
}
+ @Test
+ public void testBug4760() throws Exception {
+ final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug4760");
+ assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
+ final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug4760");
+ assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+
+ generateTestSources("/compilation/bug4760", sourcesOutputDir);
+
+ // Test if sources are compilable
+ testCompilation(sourcesOutputDir, compiledOutputDir);
+
+ cleanUp(sourcesOutputDir, compiledOutputDir);
+ }
+
/**
* Test handling nested uses-augmentations.
*
package org.opendaylight.yangtools.yang.binding;
import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
return toFirstUpper(toCamelCase(name.getLocalName()));
}
+ public static String getGetterSuffix(final QName name) {
+ checkArgument(name != null, "Name should not be null.");
+ final String candidate = toFirstUpper(toCamelCase(name.getLocalName()));
+ return ("Class".equals(candidate) ? "XmlClass" : candidate);
+ }
+
public static String getPropertyName(final String yangIdentifier) {
final String potential = toFirstLower(toCamelCase(yangIdentifier));
if ("class".equals(potential)) {