Interface DependencyManager


  • public interface DependencyManager
    Keeps track of which dependencies have been imported and which is not included. This is useful for solving the issue of when to write the full name of a class and when to only include the short name.
    Since:
    2.0
    Author:
    Emil Forslund
    • Method Detail

      • load

        boolean load​(String fullname)
        Attempts to add the specified resource to the dependency list. If the name is already taken it will return false.
        Parameters:
        fullname - the full name of the resource.
        Returns:
        true if it was added, else false
      • isLoaded

        boolean isLoaded​(String fullname)
        Returns true if the specified fullname is either:
                        (A) loaded into the dependency list;
                        (B) on the ignore list.
         
        Else it returns false.
        Parameters:
        fullname - the full name of the resource.
        Returns:
        true if it don't have to be loaded.
      • isIgnored

        boolean isIgnored​(String fullname)
        Returns true if the specified class belongs to a package that is on the ignore list.
        Parameters:
        fullname - the full name of a package or a class
        Returns:
        true if it should be ignored as a dependency
      • clearDependencies

        void clearDependencies()
        Clear all dependencies.
      • setCurrentPackage

        boolean setCurrentPackage​(String pack)
        Attempts to set the package that is currently being rendered. If a package is already set, the operation will fail and false will be returned. If the operation succeeded, true is returned and the DependencyManager will expect unsetCurrentPackage(java.lang.String) to be called later before the generation is finished.
        Parameters:
        pack - the new current package
        Returns:
        true if the operation succeeded, else false
      • unsetCurrentPackage

        boolean unsetCurrentPackage​(String pack)
        Attempts to unset the currently rendered package. If the specified package is the one that is currently being rendered, it will be unset and true will be returned. If the package specified is not correct, the current package will not be unset and false will be returned. If no package was set the operation will throw an IllegalStateException.
        Parameters:
        pack - the current package to unset
        Returns:
        true if the operation succeeded, else false
      • getCurrentPackage

        Optional<String> getCurrentPackage()
        Returns the current package if one is set, or else empty.
        Returns:
        the package
      • create

        static DependencyManager create()
        Creates and returns a new default DependencyManager.
        Returns:
        a new default DependencyManager
      • create

        static DependencyManager create​(Pattern... ignoredPatterns)
        Creates and returns a new default DependencyManager.
        Parameters:
        ignoredPatterns - to add to the ignore list
        Returns:
        a new default DependencyManager
        Throws:
        NullPointerException - if the provided ignoredPattern is null.