Class CatchClause
- java.lang.Object
-
- com.tonic.analysis.source.ast.stmt.CatchClause
-
public final class CatchClause extends Object
A catch clause of a try statement, supporting multi-catch via multiple exception types.
-
-
Constructor Summary
Constructors Constructor Description CatchClause(List<SourceType> exceptionTypes, String variableName, Statement body)Creates a catch clause over the given exception types.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Statementbody()booleanequals(Object o)List<SourceType>exceptionTypes()SourceTypegetPrimaryType()inthashCode()booleanisMultiCatch()static CatchClausemultiCatch(List<SourceType> types, String variableName, Statement body)Creates a multi-catch clause.static CatchClauseof(SourceType exceptionType, String variableName, Statement body)Creates a catch clause with a single exception type.StringtoString()StringvariableName()
-
-
-
Constructor Detail
-
CatchClause
public CatchClause(List<SourceType> exceptionTypes, String variableName, Statement body)
Creates a catch clause over the given exception types.- Parameters:
exceptionTypes- caught exception types, at least onevariableName- name of the exception variablebody- handler body- Throws:
NullPointerException- if any argument is nullIllegalArgumentException- if exceptionTypes is empty
-
-
Method Detail
-
of
public static CatchClause of(SourceType exceptionType, String variableName, Statement body)
Creates a catch clause with a single exception type.- Parameters:
exceptionType- the caught exception typevariableName- name of the exception variablebody- handler body- Returns:
- the new catch clause
-
multiCatch
public static CatchClause multiCatch(List<SourceType> types, String variableName, Statement body)
Creates a multi-catch clause.- Parameters:
types- the caught exception typesvariableName- name of the exception variablebody- handler body- Returns:
- the new catch clause
-
isMultiCatch
public boolean isMultiCatch()
- Returns:
- true if this clause catches more than one exception type
-
getPrimaryType
public SourceType getPrimaryType()
- Returns:
- the first declared exception type
-
exceptionTypes
public List<SourceType> exceptionTypes()
- Returns:
- the caught exception types, unmodifiable
-
variableName
public String variableName()
- Returns:
- the exception variable name
-
body
public Statement body()
- Returns:
- the handler body
-
-