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 thisThrowsDeclarationis declared. This can be aJavaCodeUnit, i.e. a method or constructor. It can also be aCodeUnitCallTargetwhere the resolution process resolved thisThrowsDeclarationon 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 {}
SinceCcan be assigned to eitherAorB, it follows that the inherited methodC.method()only declaresE2as its only checked Exception.
Thus theThrowsClausefor the call targetC.method()would only contain aThrowsDeclarationwith typeE2.
For further information about the resolution process ofAccessTargetstoJavaMembersconsult 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 classPredefinedfunctionsto transformThrowsDeclaration.Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.PredicatesNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasType
HasType.Predicates -
Method Summary
-
Method Details
-
getOwner
- Specified by:
getOwnerin interfaceHasOwner<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>>- Returns:
- The
ThrowsClausecontaining this declaration
-
getThrowsClause
-
getLocation
- Returns:
- The 'location' where this
ThrowsDeclarationis declared. Can be eitherJavaCodeUnitorAccessTarget.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:
getRawTypein interfaceHasType- Returns:
- The type of this
ThrowsDeclaration, e.g. for a method
thevoid method() throws SomeException {...}JavaClassrepresentingSomeExceptionwill be returned
-
hashCode
public int hashCode() -
equals
-
toString
-