use of com.github.javaparser.ast.type.IntersectionType in project javaparser by javaparser.
the class JavaParserTest method parseIntersectionType.
@Test
public void parseIntersectionType() {
String code = "(Runnable & Serializable) (() -> {})";
Expression expression = JavaParser.parseExpression(code);
Type type = expression.asCastExpr().getType();
assertTrue(type instanceof IntersectionType);
IntersectionType intersectionType = type.asIntersectionType();
assertEquals(2, intersectionType.getElements().size());
assertTrue(intersectionType.getElements().get(0) instanceof ClassOrInterfaceType);
assertEquals("Runnable", intersectionType.getElements().get(0).asClassOrInterfaceType().getNameAsString());
assertTrue(intersectionType.getElements().get(1) instanceof ClassOrInterfaceType);
assertEquals("Serializable", intersectionType.getElements().get(1).asClassOrInterfaceType().getNameAsString());
}
Aggregations