Home | History | Annotate | Download | only in body
      1 /*
      2  * Copyright (C) 2007-2010 Jlio Vilmar Gesser.
      3  * Copyright (C) 2011, 2013-2015 The JavaParser Team.
      4  *
      5  * This file is part of JavaParser.
      6  *
      7  * JavaParser can be used either under the terms of
      8  * a) the GNU Lesser General Public License as published by
      9  *     the Free Software Foundation, either version 3 of the License, or
     10  *     (at your option) any later version.
     11  * b) the terms of the Apache License
     12  *
     13  * You should have received a copy of both licenses in LICENCE.LGPL and
     14  * LICENCE.APACHE. Please refer to those files for details.
     15  *
     16  * JavaParser is distributed in the hope that it will be useful,
     17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19  * GNU Lesser General Public License for more details.
     20  */
     21 
     22 package com.github.javaparser.ast.body;
     23 
     24 import com.github.javaparser.ast.DocumentableNode;
     25 import com.github.javaparser.ast.NamedNode;
     26 import com.github.javaparser.ast.comments.JavadocComment;
     27 import com.github.javaparser.ast.expr.AnnotationExpr;
     28 import com.github.javaparser.ast.expr.Expression;
     29 import com.github.javaparser.ast.type.Type;
     30 import com.github.javaparser.ast.visitor.GenericVisitor;
     31 import com.github.javaparser.ast.visitor.VoidVisitor;
     32 
     33 import java.util.List;
     34 
     35 /**
     36  * @author Julio Vilmar Gesser
     37  */
     38 public final class AnnotationMemberDeclaration extends BodyDeclaration implements DocumentableNode, NamedNode {
     39 
     40     private int modifiers;
     41 
     42     private Type type;
     43 
     44     private String name;
     45 
     46     private Expression defaultValue;
     47 
     48     public AnnotationMemberDeclaration() {
     49     }
     50 
     51     public AnnotationMemberDeclaration(int modifiers, Type type, String name, Expression defaultValue) {
     52         setModifiers(modifiers);
     53         setType(type);
     54         setName(name);
     55         setDefaultValue(defaultValue);
     56     }
     57 
     58     public AnnotationMemberDeclaration(int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) {
     59         super(annotations);
     60         setModifiers(modifiers);
     61         setType(type);
     62         setName(name);
     63         setDefaultValue(defaultValue);
     64     }
     65 
     66     public AnnotationMemberDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, int modifiers, List<AnnotationExpr> annotations, Type type, String name, Expression defaultValue) {
     67         super(beginLine, beginColumn, endLine, endColumn, annotations);
     68         setModifiers(modifiers);
     69         setType(type);
     70         setName(name);
     71         setDefaultValue(defaultValue);
     72     }
     73 
     74     @Override
     75     public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
     76         return v.visit(this, arg);
     77     }
     78 
     79     @Override
     80     public <A> void accept(VoidVisitor<A> v, A arg) {
     81         v.visit(this, arg);
     82     }
     83 
     84     public Expression getDefaultValue() {
     85         return defaultValue;
     86     }
     87 
     88     /**
     89      * Return the modifiers of this member declaration.
     90      *
     91      * @see ModifierSet
     92      * @return modifiers
     93      */
     94     public int getModifiers() {
     95         return modifiers;
     96     }
     97 
     98     public String getName() {
     99         return name;
    100     }
    101 
    102     public Type getType() {
    103         return type;
    104     }
    105 
    106     public void setDefaultValue(Expression defaultValue) {
    107         this.defaultValue = defaultValue;
    108         setAsParentNodeOf(defaultValue);
    109     }
    110 
    111     public void setModifiers(int modifiers) {
    112         this.modifiers = modifiers;
    113     }
    114 
    115     public void setName(String name) {
    116         this.name = name;
    117     }
    118 
    119     public void setType(Type type) {
    120         this.type = type;
    121         setAsParentNodeOf(type);
    122     }
    123 
    124     @Override
    125     public void setJavaDoc(JavadocComment javadocComment) {
    126         this.javadocComment = javadocComment;
    127     }
    128 
    129     @Override
    130     public JavadocComment getJavaDoc() {
    131         return javadocComment;
    132     }
    133 
    134     private JavadocComment javadocComment;
    135 }
    136