Class WebResourcePackageManager

java.lang.Object
com.foreach.across.modules.web.resource.WebResourcePackageManager

public class WebResourcePackageManager extends Object
Allows registration of WebResourcePackage instances under a specific name. When attached to a WebResourceRegistry, the caller can simply do WebResourceRegistry.addPackage(String...) to install all resources bundled by the specific package.
See Also:
  • Constructor Details

    • WebResourcePackageManager

      public WebResourcePackageManager()
  • Method Details

    • register

      public void register(@NonNull @NonNull String name, @NonNull @NonNull WebResourcePackage webResourcePackage)
    • getPackageNames

      public Set<String> getPackageNames()
      Returns:
      names of the registered packages
    • unregister

      public Optional<WebResourcePackage> unregister(@NonNull @NonNull String name)
      Remove a package.
      Parameters:
      name - of the package to remove
      Returns:
      package that has been removed
    • getPackage

      public WebResourcePackage getPackage(@NonNull @NonNull String name)
      Get the package with the given name.
      Parameters:
      name - of the package
      Returns:
      resource package
    • extendPackage

      public boolean extendPackage(@NonNull @NonNull String name, WebResourceRule... rules)
      Extend the package registered under the current name with the given web resource rules. The rules will be bundled into a separate package and then combined with the original using WebResourcePackage.combine(WebResourcePackage, WebResourcePackage). The result will be registered under the original packaga name.

      If the package with that name is not present to begin with, nothing will be done and false will be returned.

      Parameters:
      name - of the package to extend
      rules - to append to the package
      Returns:
      true if the package was present and has been extended, false if the package was not found and no changes have been made
    • extendPackage

      public boolean extendPackage(@NonNull @NonNull String name, @NonNull @NonNull Collection<WebResourceRule> rules)
      Extend the package registered under the current name with the given web resource rules. The rules will be bundled into a separate package and then combined with the original using WebResourcePackage.combine(WebResourcePackage, WebResourcePackage). The result will be registered under the original packaga name.

      If the package with that name is not present to begin with, nothing will be done and false will be returned.

      Parameters:
      name - of the package to extend
      rules - to append to the package
      Returns:
      true if the package was present and has been extended, false if the package was not found and no changes have been made
    • extendPackage

      public boolean extendPackage(@NonNull @NonNull String name, @NonNull @NonNull WebResourcePackage extension)
      Extend the package registered under the current name with the given package. This will effectively callĀ WebResourcePackage.combine(WebResourcePackage, WebResourcePackage) with both packages and register the result under the same name.

      If the package with that name is not present to begin with, nothing will be done and false will be returned.

      Parameters:
      name - of the package to extend
      extension - to append to the package
      Returns:
      true if the package was present and has been extended, false if the package was not found and no changes have been made