use of org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor.Union in project ceylon by eclipse.
the class Wrappings method elementMapping.
static <Java, Ceylon> Wrapping<Java, Ceylon> elementMapping(TypeDescriptor $reified$Element) {
boolean allowNull = false;
if ($reified$Element.containsNull()) {
allowNull = true;
if ($reified$Element instanceof TypeDescriptor.Union && ((TypeDescriptor.Union) $reified$Element).getMembers().length == 2) {
Union union = (TypeDescriptor.Union) $reified$Element;
if (union.getMembers()[0].containsNull()) {
$reified$Element = union.getMembers()[1];
} else if (union.getMembers()[1].containsNull()) {
$reified$Element = union.getMembers()[0];
}
}
}
Wrapping<Java, Ceylon> elementWrapping;
if ($reified$Element == ceylon.language.Integer.$TypeDescriptor$) {
elementWrapping = (Wrapping) (allowNull ? TO_CEYLON_INTEGER_OR_NULL : TO_CEYLON_INTEGER);
} else if ($reified$Element == ceylon.language.Float.$TypeDescriptor$) {
elementWrapping = (Wrapping) (allowNull ? TO_CEYLON_FLOAT_OR_NULL : TO_CEYLON_FLOAT);
} else if ($reified$Element == ceylon.language.Byte.$TypeDescriptor$) {
elementWrapping = (Wrapping) (allowNull ? TO_CEYLON_BYTE_OR_NULL : TO_CEYLON_BYTE);
} else if ($reified$Element == ceylon.language.Boolean.$TypeDescriptor$) {
elementWrapping = (Wrapping) (allowNull ? TO_CEYLON_BOOLEAN_OR_NULL : TO_CEYLON_BOOLEAN);
} else if ($reified$Element == ceylon.language.Character.$TypeDescriptor$) {
elementWrapping = (Wrapping) (allowNull ? TO_CEYLON_CHARACTER_OR_NULL : TO_CEYLON_CHARACTER);
} else if ($reified$Element == ceylon.language.String.$TypeDescriptor$) {
elementWrapping = (Wrapping) (allowNull ? TO_CEYLON_STRING_OR_NULL : TO_CEYLON_STRING);
} else if ($reified$Element instanceof TypeDescriptor.Class) {
TypeDescriptor.Class classDescriptor = (TypeDescriptor.Class) $reified$Element;
if (classDescriptor.getKlass() == ceylon.language.List.class) {
elementWrapping = (Wrapping) toCeylonList(classDescriptor.getTypeArgument(0), allowNull);
} else if (classDescriptor.getKlass() == ceylon.language.Set.class) {
elementWrapping = (Wrapping) toCeylonSet(classDescriptor.getTypeArgument(0), allowNull);
} else if (classDescriptor.getKlass() == ceylon.language.Map.class) {
elementWrapping = (Wrapping) toCeylonMap(classDescriptor.getTypeArgument(0), classDescriptor.getTypeArgument(1), allowNull);
} else {
elementWrapping = allowNull ? MAYBE_IDENTITY : DEFINITE_IDENTITY;
}
} else {
elementWrapping = allowNull ? MAYBE_IDENTITY : DEFINITE_IDENTITY;
}
return elementWrapping;
}
Aggregations