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
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 {...}
ThrowsDeclaration
representingFirstException
and one representingSecondException
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThrowsDeclaration.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 boolean
equals(java.lang.Object obj)
JavaClass
getDeclaringClass()
LOCATION
getLocation()
ThrowsClause<LOCATION>
getOwner()
JavaClass
getRawType()
ThrowsClause<LOCATION>
getThrowsClause()
JavaClass
getType()
Deprecated.UsegetRawType()
insteadint
hashCode()
java.lang.String
toString()
-
-
-
Method Detail
-
getOwner
@PublicAPI(usage=ACCESS) public ThrowsClause<LOCATION> getOwner()
- Specified by:
getOwner
in interfaceHasOwner<LOCATION extends HasParameterTypes & HasReturnType & HasName.AndFullName & CanBeAnnotated & HasOwner<JavaClass>>
- Returns:
- The
ThrowsClause
containing this declaration
-
getThrowsClause
@PublicAPI(usage=ACCESS) public ThrowsClause<LOCATION> getThrowsClause()
-
getLocation
@PublicAPI(usage=ACCESS) public LOCATION getLocation()
- Returns:
- The 'location' where this
ThrowsDeclaration
is declared. Can be eitherJavaCodeUnit
orAccessTarget.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:
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()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-