Search in sources :

Example 16 with AnnotationMemberDeclaration

use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.

the class AnnotationMemberDeclarationTransformationsTest method removingDefaultValue.

@Test
public void removingDefaultValue() {
    AnnotationMemberDeclaration md = consider("int foo() default 10;");
    assertEquals(true, md.getDefaultValue().get().remove());
    assertTransformedToString("int foo();", md);
}
Also used : AnnotationMemberDeclaration(com.github.javaparser.ast.body.AnnotationMemberDeclaration) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 17 with AnnotationMemberDeclaration

use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.

the class AnnotationMemberDeclarationTransformationsTest method removingModifiers.

@Test
public void removingModifiers() {
    AnnotationMemberDeclaration md = consider("public int foo();");
    md.setModifiers(EnumSet.noneOf(Modifier.class));
    assertTransformedToString("int foo();", md);
}
Also used : Modifier(com.github.javaparser.ast.Modifier) AnnotationMemberDeclaration(com.github.javaparser.ast.body.AnnotationMemberDeclaration) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 18 with AnnotationMemberDeclaration

use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.

the class AnnotationMemberDeclarationTransformationsTest method addingDefaultValue.

// Default value
@Test
public void addingDefaultValue() {
    AnnotationMemberDeclaration md = consider("int foo();");
    md.setDefaultValue(new IntegerLiteralExpr("10"));
    assertTransformedToString("int foo() default 10;", md);
}
Also used : IntegerLiteralExpr(com.github.javaparser.ast.expr.IntegerLiteralExpr) AnnotationMemberDeclaration(com.github.javaparser.ast.body.AnnotationMemberDeclaration) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 19 with AnnotationMemberDeclaration

use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.

the class AnnotationMemberDeclarationTransformationsTest method removingJavadoc.

@Test
public void removingJavadoc() {
    AnnotationMemberDeclaration it = consider("/** Cool this annotation!*/ int foo();");
    assertTrue(it.getJavadocComment().get().remove());
    assertTransformedToString("@interface AD {  int foo(); }", it.getParentNode().get());
}
Also used : AnnotationMemberDeclaration(com.github.javaparser.ast.body.AnnotationMemberDeclaration) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 20 with AnnotationMemberDeclaration

use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.

the class AnnotationDeclarationTransformationsTest method addingMember.

// members
@Test
public void addingMember() throws IOException {
    considerExample("AnnotationDeclaration_Example3_original");
    cu.getAnnotationDeclarationByName("ClassPreamble").get().addMember(new AnnotationMemberDeclaration(EnumSet.noneOf(Modifier.class), PrimitiveType.intType(), "foo", null));
    assertTransformed("AnnotationDeclaration_Example5", cu);
}
Also used : AnnotationMemberDeclaration(com.github.javaparser.ast.body.AnnotationMemberDeclaration) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Aggregations

AnnotationMemberDeclaration (com.github.javaparser.ast.body.AnnotationMemberDeclaration)21 Test (org.junit.Test)20 AbstractLexicalPreservingTest (com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)18 CompilationUnit (com.github.javaparser.ast.CompilationUnit)2 IntegerLiteralExpr (com.github.javaparser.ast.expr.IntegerLiteralExpr)2 Modifier (com.github.javaparser.ast.Modifier)1 NodeList (com.github.javaparser.ast.NodeList)1 BlockComment (com.github.javaparser.ast.comments.BlockComment)1 Comment (com.github.javaparser.ast.comments.Comment)1 JavadocComment (com.github.javaparser.ast.comments.JavadocComment)1 LineComment (com.github.javaparser.ast.comments.LineComment)1 Name (com.github.javaparser.ast.expr.Name)1 NormalAnnotationExpr (com.github.javaparser.ast.expr.NormalAnnotationExpr)1