Class LoosePackageCouplingRule

  • All Implemented Interfaces:
    JavaParserVisitor, ImmutableLanguage, PropertySource, Rule

    public class LoosePackageCouplingRule
    extends AbstractJavaRule
    The loose package coupling Rule can be used to ensure coupling outside of a package hierarchy is minimized to all but an allowed set of classes from within the package hierarchy.

    For example, supposed you have the following package hierarchy:

    • org.sample
    • org.sample.impl
    • org.sample.util
    And the allowed class org.sample.SampleInterface.

    This rule can be used to ensure that all classes within the org.sample package and its sub-packages are not used outside of the org.sample package hierarchy. Further, the only allowed usage outside of a class in the org.sample hierarchy would be via org.sample.SampleInterface.