Package com.github.javaparser
Class ParseResult<T>
- java.lang.Object
-
- com.github.javaparser.ParseResult<T>
-
public class ParseResult<T> extends java.lang.Object
The results given when parsing with an instance of JavaParser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ParseResult.PostProcessor
A post processor that can be added to ParserConfiguration to add some processing right after parsing.
-
Field Summary
Fields Modifier and Type Field Description private CommentsCollection
commentsCollection
private java.util.List<Problem>
problems
private T
result
-
Constructor Summary
Constructors Constructor Description ParseResult(T result, java.util.List<Problem> problems, CommentsCollection commentsCollection)
General constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<CommentsCollection>
getCommentsCollection()
Problem
getProblem(int i)
java.util.List<Problem>
getProblems()
java.util.Optional<T>
getResult()
void
ifSuccessful(java.util.function.Consumer<T> consumer)
Calls the consumer with the result if parsing was succesful.boolean
isSuccessful()
java.lang.String
toString()
-
-
-
Field Detail
-
result
private final T result
-
problems
private final java.util.List<Problem> problems
-
commentsCollection
private final CommentsCollection commentsCollection
-
-
Constructor Detail
-
ParseResult
public ParseResult(T result, java.util.List<Problem> problems, CommentsCollection commentsCollection)
General constructor.- Parameters:
result
- the AST, or empty if it wasn't created.problems
- a list of encountered parsing problems.
-
-
Method Detail
-
isSuccessful
public boolean isSuccessful()
- Returns:
- if parsing was successful, meaning no errors of any kind were encountered.
-
ifSuccessful
public void ifSuccessful(java.util.function.Consumer<T> consumer)
Calls the consumer with the result if parsing was succesful.
-
getProblems
public java.util.List<Problem> getProblems()
- Returns:
- the list of encountered parsing problems. Empty when no problems were encountered.
-
getProblem
public Problem getProblem(int i)
- Returns:
- the
i
'th encountered parsing problem. May throwIndexOutOfBoundsException
.
-
getCommentsCollection
public java.util.Optional<CommentsCollection> getCommentsCollection()
- Returns:
- the complete collection of comments encountered while parsing.
-
getResult
public java.util.Optional<T> getResult()
- Returns:
- the AST of the parsed source code, or empty if parsing failed completely.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-