add automatic conversions to violation handling #1251
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The extensive freedom of how to create a
ConditionEvent
causes problems for any client that needs more structured results (e.g. tools).ViolationHandler
provides a convenient API to obtain only those sort of violations that can be handled by a client (e.g. tackling dependencies).However, the type of the
correspondingObject
attached to theConditionEvent
can take many forms.From classes to methods, method calls, dependencies or aggregated dependencies (like module dependencies) it's hard to determine the possibilities and handle them all.
Furthermore, the type of some objects (e.g.
ComponentDependency
isn't even public,so there is hardly any clean way to handle these objects.
To mitigate this a little we now support transparent conversions between compatible objects.
E.g. a component dependency can also be considered a set of class dependencies.
ViolationHandler
now allows to be used including these conversions that are implemented by standard ArchUnit objects where reasonable.This allows e.g. to obtain all module dependencies as
Set<Dependency>
for every violation.