Package com.tngtech.archunit.core.domain
Class ThrowsDeclaration<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>>
java.lang.Object
com.tngtech.archunit.core.domain.ThrowsDeclaration<LOCATION>
- Type Parameters:
LOCATION
- Represents the 'location' where thisThrowsDeclaration
is declared. This can be aJavaCodeUnit
, i.e. a method or constructor. It can also be aCodeUnitCallTarget
where the resolution process resolved thisThrowsDeclaration
on all resolved targets.
To further elaborate, suppose we have three interfaces
interface A { void method() throws E1, E2{...} }
interface B { void method() throws E2, E3{...} }
interface C extends A, B {}
SinceC
can be assigned to eitherA
orB
, it follows that the inherited methodC.method()
only declaresE2
as its only checked Exception.
Thus theThrowsClause
for the call targetC.method()
would only contain aThrowsDeclaration
with typeE2
.
For further information about the resolution process ofAccessTargets
toJavaMembers
consult the documentation atAccessTarget
.
- All Implemented Interfaces:
HasOwner<ThrowsClause<LOCATION>>
,HasType
@PublicAPI(usage=ACCESS)
public final class ThrowsDeclaration<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>>
extends Object
implements HasType, HasOwner<ThrowsClause<LOCATION>>
Represents one declared exception of a
ThrowsClause
. I.e. for
void someMethod() throws FirstException, SecondException {...}
there would be one ThrowsDeclaration
representing FirstException
and one representing
SecondException
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Predefinedfunctions
to transformThrowsDeclaration
.Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.Predicates
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasType
HasType.Predicates
-
Method Summary
-
Method Details
-
getOwner
- Specified by:
getOwner
in interfaceHasOwner<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>>
- Returns:
- The
ThrowsClause
containing this declaration
-
getThrowsClause
-
getLocation
- Returns:
- The 'location' where this
ThrowsDeclaration
is declared. Can be eitherJavaCodeUnit
orAccessTarget.CodeUnitCallTarget
. Compare docs atThrowsDeclaration
.
-
getDeclaringClass
- Returns:
- The class that declares the
ThrowsDeclaration
(i.e. method, constructor, method call target, constructor call target) containing thisThrowsDeclaration
-
getType
-
getRawType
- Specified by:
getRawType
in interfaceHasType
- Returns:
- The type of this
ThrowsDeclaration
, e.g. for a method
thevoid method() throws SomeException {...}
JavaClass
representingSomeException
will be returned
-
hashCode
public int hashCode() -
equals
-
toString
-