1 | /* |
---|---|
2 | * Copyright (C) 2007-2010 JĂșlio Vilmar Gesser. |
3 | * Copyright (C) 2011, 2013-2020 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 | package com.github.javaparser.ast.comments; |
22 | |
23 | import com.github.javaparser.ast.AllFieldsConstructor; |
24 | import com.github.javaparser.ast.visitor.GenericVisitor; |
25 | import com.github.javaparser.ast.visitor.VoidVisitor; |
26 | import com.github.javaparser.ast.Node; |
27 | import com.github.javaparser.ast.visitor.CloneVisitor; |
28 | import com.github.javaparser.metamodel.BlockCommentMetaModel; |
29 | import com.github.javaparser.metamodel.JavaParserMetaModel; |
30 | import com.github.javaparser.TokenRange; |
31 | import java.util.function.Consumer; |
32 | import java.util.Optional; |
33 | import com.github.javaparser.ast.Generated; |
34 | |
35 | /** |
36 | * <p> |
37 | * AST node that represent block comments. |
38 | * </p> |
39 | * Block comments can has multi lines and are delimited by "/*" and |
40 | * "*/". |
41 | * |
42 | * @author Julio Vilmar Gesser |
43 | */ |
44 | public class BlockComment extends Comment { |
45 | |
46 | public BlockComment() { |
47 | this(null, "empty"); |
48 | } |
49 | |
50 | @AllFieldsConstructor |
51 | public BlockComment(String content) { |
52 | this(null, content); |
53 | } |
54 | |
55 | /** |
56 | * This constructor is used by the parser and is considered private. |
57 | */ |
58 | @Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator") |
59 | public BlockComment(TokenRange tokenRange, String content) { |
60 | super(tokenRange, content); |
61 | customInitialization(); |
62 | } |
63 | |
64 | @Override |
65 | @Generated("com.github.javaparser.generator.core.node.AcceptGenerator") |
66 | public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) { |
67 | return v.visit(this, arg); |
68 | } |
69 | |
70 | @Override |
71 | @Generated("com.github.javaparser.generator.core.node.AcceptGenerator") |
72 | public <A> void accept(final VoidVisitor<A> v, final A arg) { |
73 | v.visit(this, arg); |
74 | } |
75 | |
76 | @Override |
77 | @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator") |
78 | public boolean remove(Node node) { |
79 | if (node == null) |
80 | return false; |
81 | return super.remove(node); |
82 | } |
83 | |
84 | @Override |
85 | @Generated("com.github.javaparser.generator.core.node.CloneGenerator") |
86 | public BlockComment clone() { |
87 | return (BlockComment) accept(new CloneVisitor(), null); |
88 | } |
89 | |
90 | @Override |
91 | @Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator") |
92 | public BlockCommentMetaModel getMetaModel() { |
93 | return JavaParserMetaModel.blockCommentMetaModel; |
94 | } |
95 | |
96 | @Override |
97 | @Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator") |
98 | public boolean replace(Node node, Node replacementNode) { |
99 | if (node == null) |
100 | return false; |
101 | return super.replace(node, replacementNode); |
102 | } |
103 | |
104 | @Override |
105 | @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator") |
106 | public boolean isBlockComment() { |
107 | return true; |
108 | } |
109 | |
110 | @Override |
111 | @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator") |
112 | public BlockComment asBlockComment() { |
113 | return this; |
114 | } |
115 | |
116 | @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator") |
117 | public void ifBlockComment(Consumer<BlockComment> action) { |
118 | action.accept(this); |
119 | } |
120 | |
121 | @Override |
122 | @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator") |
123 | public Optional<BlockComment> toBlockComment() { |
124 | return Optional.of(this); |
125 | } |
126 | } |
127 |
Members