AIPR - Avoid Implementation Packages Referencing
This rule helps you avoid referencing packages that normally should not be referenced. For example, if you use Facade or AbstractFactory patterns, you can make sure that nobody uses direct calls to the underlaying classes' constructors.
In this case you can divide your packages into interface and implementation packages, and ensure that nobody ever refers to the implementation packages, while the interface packages are accessible for reference.
You can set up two lists of packages, the allowed (interface) and banned (implementation) packages. For each class reference in source code, this rule verifies, whether the package where this class belongs, is in the allowed and not in the banned list.
Package names in the list may be| '*' | - any package is allowed (banned) |
| package name | - this package is allowed (banned) |
| package name postfixed by '*' | - any subpackage of the given package is allowed (banned) |
In case of conflict, the narrower rule
prevails. For example, if you specify
allowed list as
*
com.mycompany.openapi.*
and banned list as
com.mycompany.*
than all subpackages of com.mycompany package would be banned
except for those belonging to com.mycompany.openapi
subpackage.