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
public final class ThrowsDeclaration<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>> extends java.lang.Object implements HasType, HasOwner<ThrowsClause<LOCATION>>
Represents one declared exception of aThrowsClause. I.e. for
there would be onevoid someMethod() throws FirstException, SecondException {...}ThrowsDeclarationrepresentingFirstExceptionand one representingSecondException
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThrowsDeclaration.Functions-
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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)JavaClassgetDeclaringClass()LOCATIONgetLocation()ThrowsClause<LOCATION>getOwner()JavaClassgetRawType()ThrowsClause<LOCATION>getThrowsClause()JavaClassgetType()Deprecated.UsegetRawType()insteadinthashCode()java.lang.StringtoString()
-
-
-
Method Detail
-
getOwner
@PublicAPI(usage=ACCESS) public ThrowsClause<LOCATION> getOwner()
- Specified by:
getOwnerin interfaceHasOwner<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>>- Returns:
- The
ThrowsClausecontaining this declaration
-
getThrowsClause
@PublicAPI(usage=ACCESS) public ThrowsClause<LOCATION> getThrowsClause()
-
getLocation
@PublicAPI(usage=ACCESS) public LOCATION getLocation()
- Returns:
- The 'location' where this
ThrowsDeclarationis declared. Can be eitherJavaCodeUnitorAccessTarget.CodeUnitCallTarget. Compare docs atThrowsDeclaration.
-
getDeclaringClass
@PublicAPI(usage=ACCESS) public JavaClass getDeclaringClass()
- Returns:
- The class that declares the
ThrowsDeclaration(i.e. method, constructor, method call target, constructor call target) containing thisThrowsDeclaration
-
getType
@Deprecated @PublicAPI(usage=ACCESS) public JavaClass getType()
Deprecated.UsegetRawType()instead
-
getRawType
@PublicAPI(usage=ACCESS) public JavaClass 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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-