1/*
2 * Copyright (C) 2007-2010 Júlio 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
22package com.github.javaparser.ast.body;
23
24import com.github.javaparser.ast.DocumentableNode;
25import com.github.javaparser.ast.comments.JavadocComment;
26import com.github.javaparser.ast.stmt.BlockStmt;
27import com.github.javaparser.ast.visitor.GenericVisitor;
28import com.github.javaparser.ast.visitor.VoidVisitor;
29
30/**
31 * @author Julio Vilmar Gesser
32 */
33public final class InitializerDeclaration extends BodyDeclaration implements DocumentableNode {
34
35    private boolean isStatic;
36
37    private BlockStmt block;
38
39    public InitializerDeclaration() {
40    }
41
42    public InitializerDeclaration(boolean isStatic, BlockStmt block) {
43        super(null);
44        setStatic(isStatic);
45        setBlock(block);
46    }
47
48    public InitializerDeclaration(int beginLine, int beginColumn, int endLine, int endColumn, boolean isStatic, BlockStmt block) {
49        super(beginLine, beginColumn, endLine, endColumn, null);
50        setStatic(isStatic);
51        setBlock(block);
52    }
53
54    @Override
55    public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
56        return v.visit(this, arg);
57    }
58
59    @Override
60    public <A> void accept(VoidVisitor<A> v, A arg) {
61        v.visit(this, arg);
62    }
63
64    public BlockStmt getBlock() {
65        return block;
66    }
67
68    public boolean isStatic() {
69        return isStatic;
70    }
71
72    public void setBlock(BlockStmt block) {
73        this.block = block;
74		setAsParentNodeOf(this.block);
75    }
76
77    public void setStatic(boolean isStatic) {
78        this.isStatic = isStatic;
79    }
80
81    @Override
82    public void setJavaDoc(JavadocComment javadocComment) {
83        this.javadocComment = javadocComment;
84    }
85
86    @Override
87    public JavadocComment getJavaDoc() {
88        return javadocComment;
89    }
90
91    private JavadocComment javadocComment;
92}
93