use of com.github.javaparser.ast.expr.IntegerLiteralExpr in project javaparser by javaparser.
the class ModifierVisitorTest method binaryExprReturnsRightExpressionWhenLeftSideIsRemoved.
@Test
public void binaryExprReturnsRightExpressionWhenLeftSideIsRemoved() {
final Expression expression = parseExpression("1+2");
final Visitable result = expression.accept(new ModifierVisitor<Void>() {
public Visitable visit(IntegerLiteralExpr integerLiteralExpr, Void arg) {
if (integerLiteralExpr.getValue().equals("2")) {
return null;
}
return integerLiteralExpr;
}
}, null);
assertEquals("1", result.toString());
}
use of com.github.javaparser.ast.expr.IntegerLiteralExpr in project javaparser by javaparser.
the class AnnotationMemberDeclarationTest method removeDefaultValueWhenDefaultValueIsPresent.
@Test
public void removeDefaultValueWhenDefaultValueIsPresent() {
AnnotationMemberDeclaration decl = new AnnotationMemberDeclaration();
SimpleName name = new SimpleName("foo");
decl.setName(name);
Expression defaultValue = new IntegerLiteralExpr("2");
decl.setDefaultValue(defaultValue);
decl.removeDefaultValue();
assertFalse(defaultValue.getParentNode().isPresent());
}
use of com.github.javaparser.ast.expr.IntegerLiteralExpr in project javaparser by javaparser.
the class NodeTest method conditionalFindAll.
@Test
public void conditionalFindAll() {
Expression e = parseExpression("1+2+3");
List<IntegerLiteralExpr> ints = e.findAll(IntegerLiteralExpr.class, n -> n.asInt() > 1);
assertEquals("[2, 3]", ints.toString());
}
use of com.github.javaparser.ast.expr.IntegerLiteralExpr in project javaparser by javaparser.
the class NodeTest method typeOnlyFindFirst.
@Test
public void typeOnlyFindFirst() {
Expression e = parseExpression("1+2+3");
Optional<IntegerLiteralExpr> ints = e.findFirst(IntegerLiteralExpr.class);
assertEquals("Optional[1]", ints.toString());
}
use of com.github.javaparser.ast.expr.IntegerLiteralExpr in project javaparser by javaparser.
the class NodeTest method typeOnlyFindAll.
@Test
public void typeOnlyFindAll() {
Expression e = parseExpression("1+2+3");
List<IntegerLiteralExpr> ints = e.findAll(IntegerLiteralExpr.class);
assertEquals("[1, 2, 3]", ints.toString());
}
Aggregations