Top Description Methods
com.github.javaparser.ast.nodeTypes

public Interface NodeWithThrownExceptions<N extends Node>

Known Direct Implementers
com.github.javaparser.ast.body.CallableDeclaration, com.github.javaparser.ast.body.ConstructorDeclaration, com.github.javaparser.ast.body.MethodDeclaration
Imports
com.github.javaparser.ast.Node, .NodeList, com.github.javaparser.ast.type.ReferenceType

A node that declares the types of exception it throws.

Method Summary

Modifier and TypeMethod and Description
public default N

Returns:

this
addThrownException
(ReferenceType
the exception type
throwType
)

Adds this type to the throws clause

public default N

Returns:

this
addThrownException
(Class<? extends Throwable>
the exception class
clazz
)

Adds this class to the throws clause

public default ReferenceType
public NodeList<ReferenceType>
public default boolean

Returns:

true if found in throws clause, false if not
isThrown
(Class<? extends Throwable>
the class of the exception
clazz
)

Check whether this elements throws this exception class.

public default boolean

Returns:

true if found in throws clause, false if not
isThrown
(String
the class of the exception
throwableName
)

Check whether this elements throws this exception class Note that this is simply a text compare, no actual type resolution takes place.

public N
public void

Method Detail

addThrownExceptionback to summary
public default N addThrownException(ReferenceType throwType)

Adds this type to the throws clause

Parameters
throwType:ReferenceType

the exception type

Returns:N

this

Annotations
@SuppressWarnings:unchecked
addThrownExceptionback to summary
public default N addThrownException(Class<? extends Throwable> clazz)

Adds this class to the throws clause

Parameters
clazz:Class<? extends Throwable>

the exception class

Returns:N

this

getThrownExceptionback to summary
public default ReferenceType getThrownException(int i)
getThrownExceptionsback to summary
public NodeList<ReferenceType> getThrownExceptions()
isThrownback to summary
public default boolean isThrown(Class<? extends Throwable> clazz)

Check whether this elements throws this exception class. Note that this is simply a text compare of the simple name of the class, no actual type resolution takes place.

Parameters
clazz:Class<? extends Throwable>

the class of the exception

Returns:boolean

true if found in throws clause, false if not

isThrownback to summary
public default boolean isThrown(String throwableName)

Check whether this elements throws this exception class Note that this is simply a text compare, no actual type resolution takes place.

Parameters
throwableName:String

the class of the exception

Returns:boolean

true if found in throws clause, false if not

setThrownExceptionsback to summary
public N setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
tryAddImportToParentCompilationUnitback to summary
public void tryAddImportToParentCompilationUnit(Class<?> clazz)