-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As a next step to fully support generics within ArchUnit this PR adds support for generic superclasses. In particular * add `Optional<JavaType> JavaClass.getSuperclass()`, which will return a `JavaParameterizedType` for a parameterized superclass and the raw type otherwise * add all type arguments of generic superclasses to `JavaClass.directDependencies{From/To}Self` Example: ArchUnit would now detect `String` as a `Dependency` of `class Foo extends Base<List<? super String>>` It contains a minor breaking change: Before it was possible to receive a `JavaParameterizedType` without any type arguments. I.e. for `class Foo<T extends String>` the upper bound of `T` would actually be a `JavaParameterizedType` of type `String` without any type arguments. This is inconsistent to the Java Reflection API (and doesn't really make sense), so I have changed this within the PR to return a `JavaClass` instead. If any users of ArchUnit `0.15.0` (where this API was introduced) would use this low-level API and assumed that every `JavaType` within a type signature is either `JavaTypeVariable`, `JavaWildcard` or `JavaParameterizedType`, then this code might break now. I consider the danger slim though, because most users are probably either just interested in the `Dependencies` caused by type parameter bounds (which haven't changed) or handle all possible subclasses of `JavaType`, which would then include `JavaClass` again.
- Loading branch information
Showing
112 changed files
with
1,836 additions
and
893 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...plain/src/main/java/com/tngtech/archunit/example/layers/service/SpecialServiceHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tngtech.archunit.example.layers.service; | ||
|
||
import java.util.HashMap; | ||
import java.util.Set; | ||
|
||
import com.tngtech.archunit.example.layers.controller.SomeUtility; | ||
import com.tngtech.archunit.example.layers.controller.one.SomeEnum; | ||
|
||
public class SpecialServiceHelper extends ServiceHelper<SomeUtility, HashMap<?, Set<? super SomeEnum>>> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dparty/ThirdPartySubClassWithProblem.java → ...dparty/ThirdPartySubclassWithProblem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.tngtech.archunit.example.layers.thirdparty; | ||
|
||
public class ThirdPartySubClassWithProblem extends ThirdPartyClassWithProblem { | ||
public class ThirdPartySubclassWithProblem extends ThirdPartyClassWithProblem { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.