Class AbstractImportRule

    • Field Detail

      • allowed

        private final boolean allowed
        Indicates whether to allow access or not.
      • localOnly

        private final boolean localOnly
        Indicates if the rule only applies to this package.
      • regExp

        private final boolean regExp
        Indicates if the name is to be interpreted as a regular expression.
    • Constructor Detail

      • AbstractImportRule

        protected AbstractImportRule​(boolean allow,
                                     boolean localOnly,
                                     boolean regExp)
        Constructs an instance.
        Parameters:
        allow - whether to allow access.
        localOnly - whether the rule is to be applied locally only.
        regExp - whether the name is to be interpreted as a regular expression.
    • Method Detail

      • verifyImport

        public abstract AccessResult verifyImport​(String forImport)
        Verifies whether a package name is used.
        Parameters:
        forImport - the import to check.
        Returns:
        a result AccessResult indicating whether it can be used.
      • isLocalOnly

        public boolean isLocalOnly()
        Return true if the guard is to only be applied locally or false.
        Returns:
        whether the guard is to only be applied locally.
      • isRegExp

        protected boolean isRegExp()
        Return true if the name is to be interpreted as a regular expression or false.
        Returns:
        whether the name is to be interpreted as a regular expression.
      • calculateResult

        protected AccessResult calculateResult​(boolean matched)
        Returns the appropriate AccessResult based on whether there was a match and if the rule is to allow access.
        Parameters:
        matched - indicates whether there was a match.
        Returns:
        An appropriate AccessResult.