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.NamedNode;
     25 import com.github.javaparser.ast.expr.AnnotationExpr;
     26 import com.github.javaparser.ast.expr.NameExpr;
     27 
     28 import java.util.List;
     29 
     30 /**
     31  * @author Julio Vilmar Gesser
     32  */
     33 public abstract class TypeDeclaration extends BodyDeclaration implements NamedNode {
     34 
     35 	private NameExpr name;
     36 
     37 	private int modifiers;
     38 
     39 	private List<BodyDeclaration> members;
     40 
     41 	public TypeDeclaration() {
     42 	}
     43 
     44 	public TypeDeclaration(int modifiers, String name) {
     45 		setName(name);
     46 		setModifiers(modifiers);
     47 	}
     48 
     49 	public TypeDeclaration(List<AnnotationExpr> annotations,
     50 			int modifiers, String name,
     51 			List<BodyDeclaration> members) {
     52 		super(annotations);
     53 		setName(name);
     54 		setModifiers(modifiers);
     55 		setMembers(members);
     56 	}
     57 
     58 	public TypeDeclaration(int beginLine, int beginColumn, int endLine,
     59 			int endColumn, List<AnnotationExpr> annotations,
     60 			int modifiers, String name,
     61 			List<BodyDeclaration> members) {
     62 		super(beginLine, beginColumn, endLine, endColumn, annotations);
     63 		setName(name);
     64 		setModifiers(modifiers);
     65 		setMembers(members);
     66 	}
     67 
     68 	public final List<BodyDeclaration> getMembers() {
     69 		return members;
     70 	}
     71 
     72 	/**
     73 	 * Return the modifiers of this type declaration.
     74 	 *
     75 	 * @see ModifierSet
     76 	 * @return modifiers
     77 	 */
     78 	public final int getModifiers() {
     79 		return modifiers;
     80 	}
     81 
     82 	public final String getName() {
     83 		return name.getName();
     84 	}
     85 
     86 	public void setMembers(List<BodyDeclaration> members) {
     87 		this.members = members;
     88 		setAsParentNodeOf(this.members);
     89 	}
     90 
     91 	public final void setModifiers(int modifiers) {
     92 		this.modifiers = modifiers;
     93 	}
     94 
     95 	public final void setName(String name) {
     96 		this.name = new NameExpr(name);
     97 	}
     98 
     99     public final void setNameExpr(NameExpr nameExpr) {
    100       this.name = nameExpr;
    101     }
    102 
    103     public final NameExpr getNameExpr() {
    104       return name;
    105     }
    106 }
    107