JavaParser Source Viewer

Home|JavaParser/com/github/javaparser/ast/comments/LineComment.java
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 */
21package com.github.javaparser.ast.comments;
22
23import com.github.javaparser.ast.AllFieldsConstructor;
24import com.github.javaparser.ast.visitor.GenericVisitor;
25import com.github.javaparser.ast.visitor.VoidVisitor;
26import com.github.javaparser.ast.Node;
27import com.github.javaparser.ast.visitor.CloneVisitor;
28import com.github.javaparser.metamodel.LineCommentMetaModel;
29import com.github.javaparser.metamodel.JavaParserMetaModel;
30import com.github.javaparser.TokenRange;
31import java.util.function.Consumer;
32import java.util.Optional;
33import com.github.javaparser.ast.Generated;
34
35/**
36 * <p>
37 * AST node that represent line comments.
38 * </p>
39 * Line comments start with "//" and finish at the end of the line ("\n").
40 *
41 * @author Julio Vilmar Gesser
42 */
43public class LineComment extends Comment {
44
45    public LineComment() {
46        this(null"empty");
47    }
48
49    @AllFieldsConstructor
50    public LineComment(String content) {
51        this(nullcontent);
52    }
53
54    /**
55     * This constructor is used by the parser and is considered private.
56     */
57    @Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
58    public LineComment(TokenRange tokenRangeString content) {
59        super(tokenRangecontent);
60        customInitialization();
61    }
62
63    @Override
64    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
65    public <RAR accept(final GenericVisitor<RAvfinal A arg) {
66        return v.visit(this, arg);
67    }
68
69    @Override
70    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
71    public <Avoid accept(final VoidVisitor<Avfinal A arg) {
72        v.visit(this, arg);
73    }
74
75    @Override
76    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
77    public boolean isLineComment() {
78        return true;
79    }
80
81    @Override
82    @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
83    public boolean remove(Node node) {
84        if (node == null)
85            return false;
86        return super.remove(node);
87    }
88
89    @Override
90    @Generated("com.github.javaparser.generator.core.node.CloneGenerator")
91    public LineComment clone() {
92        return (LineCommentaccept(new CloneVisitor(), null);
93    }
94
95    @Override
96    @Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator")
97    public LineCommentMetaModel getMetaModel() {
98        return JavaParserMetaModel.lineCommentMetaModel;
99    }
100
101    @Override
102    @Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
103    public boolean replace(Node nodeNode replacementNode) {
104        if (node == null)
105            return false;
106        return super.replace(nodereplacementNode);
107    }
108
109    @Override
110    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
111    public LineComment asLineComment() {
112        return this;
113    }
114
115    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
116    public void ifLineComment(Consumer<LineCommentaction) {
117        action.accept(this);
118    }
119
120    @Override
121    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
122    public Optional<LineCommenttoLineComment() {
123        return Optional.of(this);
124    }
125}
126
MembersX
LineComment:accept
LineComment:replace
LineComment:getMetaModel
LineComment:toLineComment
LineComment:LineComment
LineComment:isLineComment
LineComment:asLineComment
LineComment:ifLineComment
LineComment:clone
LineComment:remove
Members
X