Class CombinedTypeSolver
java.lang.Object
com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver
- All Implemented Interfaces:
TypeSolver
A container for type solvers. All solving is done by the contained type solvers.
This helps you when an API asks for a single type solver, but you need several.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvides some convenience exception handler implementations -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<TypeSolver> A predicate which determines what to do if an exception is raised during the parsing process.private TypeSolverprivate final Cache<String, SymbolReference<ResolvedReferenceTypeDeclaration>> Fields inherited from interface TypeSolver
JAVA_LANG_OBJECT, JAVA_LANG_RECORD -
Constructor Summary
ConstructorsConstructorDescriptionCombinedTypeSolver(TypeSolver... elements) CombinedTypeSolver(Iterable<TypeSolver> elements) CombinedTypeSolver(Predicate<Exception> exceptionHandler, TypeSolver... elements) CombinedTypeSolver(Predicate<Exception> exceptionHandler, Iterable<TypeSolver> elements) CombinedTypeSolver(Predicate<Exception> exceptionHandler, Iterable<TypeSolver> elements, Cache<String, SymbolReference<ResolvedReferenceTypeDeclaration>> typeCache) Create a new instance ofCombinedTypeSolverwith a custom symbol cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(TypeSolver typeSolver) Append a type solver to the current solver.voidadd(TypeSolver typeSolver, boolean resetCache) Append a type solver to the current solver.Parent of the this TypeSolver.voidsetExceptionHandler(Predicate<Exception> exceptionHandler) voidsetParent(TypeSolver parent) Set the parent of this TypeSolver.Solve the given type.tryToSolveType(String name) Try to solve the type with the given name.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TypeSolver
getRoot, getSolvedJavaLangObject, getSolvedJavaLangRecord, hasType
-
Field Details
-
typeCache
-
parent
-
elements
-
exceptionHandler
A predicate which determines what to do if an exception is raised during the parsing process. If it returnstruethe exception will be ignored, and solving will continue using the next solver in line. If it returnsfalsethe exception will be thrown, stopping the solving process. Main use case for this is to circumvent bugs or missing functionality in some type solvers. If for example solver A has a bug resulting in aNullPointerException, you could use awhitelistto ignore that type of exception. A secondary solver would then be able to step in when such an error occurs.- See Also:
-
-
Constructor Details
-
CombinedTypeSolver
-
CombinedTypeSolver
-
CombinedTypeSolver
-
CombinedTypeSolver
- See Also:
-
CombinedTypeSolver
public CombinedTypeSolver(Predicate<Exception> exceptionHandler, Iterable<TypeSolver> elements, Cache<String, SymbolReference<ResolvedReferenceTypeDeclaration>> typeCache) Create a new instance ofCombinedTypeSolverwith a custom symbol cache.- Parameters:
exceptionHandler- How exception should be handled.elements- The list of elements to include by default.typeCache- The cache to be used to store symbols.- See Also:
-
-
Method Details
-
setExceptionHandler
-
getParent
Description copied from interface:TypeSolverParent of the this TypeSolver. This can return null.- Specified by:
getParentin interfaceTypeSolver
-
setParent
Description copied from interface:TypeSolverSet the parent of this TypeSolver.- Specified by:
setParentin interfaceTypeSolver
-
add
Append a type solver to the current solver.- Parameters:
typeSolver- The type solver to be appended.resetCache- If should reset the cache when the solver is inserted.
-
add
Append a type solver to the current solver.
By default the cached values will be removed.- Parameters:
typeSolver- The type solver to be appended.
-
tryToSolveType
Description copied from interface:TypeSolverTry to solve the type with the given name. It always return a SymbolReference which can be solved or unsolved.- Specified by:
tryToSolveTypein interfaceTypeSolver
-
solveType
Description copied from interface:TypeSolverSolve the given type. Either the type is found and returned or an UnsolvedSymbolException is thrown.- Specified by:
solveTypein interfaceTypeSolver- Throws:
UnsolvedSymbolException
-