annotateDeprecatedIfNecessary(typedef, builder);
- if (javaType instanceof ConcreteType && "String".equals(javaType.getName()) && typedef.getBaseType() != null) {
+ if (javaType instanceof ConcreteType
+ // FIXME: This looks very suspicious: we should by checking for Types.STRING
+ && "String".equals(javaType.getName()) && typedef.getBaseType() != null) {
addStringRegExAsConstant(builder, resolveRegExpressions(typedef));
}
addUnits(builder, typedef);
} else {
Type baseType = SIMPLE_TYPES.get(subName);
if (baseType == null) {
- // This has to be a reference to a typedef, let's lookup it up and pick the its type
+ // This has to be a reference to a typedef, let's lookup it up and pick up its type
final AbstractTypeObjectGenerator<?> baseGen = verifyNotNull(
dependencies.baseTypes.get(subName), "Cannot resolve base type %s in %s", subName,
definingStatement);
}
}
+ expressions.putAll(resolveRegExpressions(subType.getTypeDefinition()));
+
generatedType = restrictType(baseType,
BindingGeneratorUtil.getRestrictions(type.getTypeDefinition()), builderFactory);
}
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.model.util.TypeConstants;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
import org.opendaylight.yangtools.yang.common.Empty;
CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
}
+ @Test
+ public void testUnionStringPatterns() throws Exception {
+ final File sourcesOutputDir = CompilationTestUtils.generatorOutput("union-string-pattern");
+ final File compiledOutputDir = CompilationTestUtils.compilerOutput("union-string-pattern");
+ generateTestSources("/compilation/union-string-pattern", sourcesOutputDir);
+ CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
+
+ final ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
+ final Class<?> fooClass = Class.forName(CompilationTestUtils.BASE_PKG + ".foo.norev.Foo", true, loader);
+
+ final Field patterns = fooClass.getDeclaredField(TypeConstants.PATTERN_CONSTANT_NAME);
+ assertEquals(List.class, patterns.getType());
+
+ CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
+ }
+
private static void testReturnTypeIdentityref(final Class<?> clazz, final String methodName,
final String returnTypeStr) throws NoSuchMethodException {
Method method = clazz.getMethod(methodName);