Class Resources<R extends Resource<R> & Comparable<? super R>>

java.lang.Object
com.aoapps.web.resources.registry.Resources<R>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Scripts, Styles

public class Resources<R extends Resource<R> & Comparable<? super R>> extends Object implements Serializable
A set of resources for a single class.
Author:
AO Industries, Inc.
See Also:
  • Constructor Details

    • Resources

      protected Resources()
    • Resources

      protected Resources(Resources<R> other)
      Copy constructor.
    • Resources

      protected Resources(Collection<? extends Resources<R>> others)
      Union constructor.
  • Method Details

    • copy

      protected Resources<R> copy()
      Gets a deep copy of these resources.
    • add

      public boolean add(R resource)
      Adds a new resource, if not already present.
      Returns:
      true if the resource was added, or false if already exists and was not added
    • add

      public Resources<R> add(Iterable<? extends R> resources)
      Adds new resources, if not already present.
    • add

      public Resources<R> add(R... resources)
      Adds new resources, if not already present.
    • remove

      public boolean remove(R resource)
      Removes a resource.
      Returns:
      true if the resource was removed, or false if the resource was not found
    • remove

      public Resources<R> remove(Iterable<? extends R> resources)
      Removes resources.
    • remove

      public Resources<R> remove(R... resources)
      Removes resources.
    • checkOrdering

      protected void checkOrdering(R before, R after)
      Checks that the before and after ordering is allowed. This is called outside of the synchronized block.
      Throws:
      IllegalArgumentException - if the ordering is not allowed
    • addOrdering

      public boolean addOrdering(boolean required, R before, R after)
      Adds an ordering constraint between two resources.
      Returns:
      true if the ordering was added, or false if already exists and was not added
    • addOrdering

      public boolean addOrdering(R before, R after)
      Adds a required ordering constraint between two resources.
    • addOrdering

      public Resources<R> addOrdering(boolean required, Iterable<? extends R> resources)
      Adds ordering constraints between multiple resources, if not already present.
    • addOrdering

      public Resources<R> addOrdering(Iterable<? extends R> resources)
      Adds required ordering constraints between multiple resources, if not already present.
    • addOrdering

      public Resources<R> addOrdering(boolean required, R... resources)
      Adds ordering constraints between multiple resources, if not already present.
    • addOrdering

      public Resources<R> addOrdering(R... resources)
      Adds required ordering constraints between multiple resources, if not already present.
    • removeOrdering

      public boolean removeOrdering(boolean required, R before, R after)
      Removes an ordering constraint between two resources.
      Returns:
      true if the ordering was removed, or false if the ordering was not found
    • removeOrdering

      public boolean removeOrdering(R before, R after)
      Removes a required ordering constraint between two resources.
    • removeOrdering

      public Resources<R> removeOrdering(boolean required, Iterable<? extends R> resources)
      Removes ordering constraints between multiple resources.
    • removeOrdering

      public Resources<R> removeOrdering(Iterable<? extends R> resources)
      Removes required ordering constraints between multiple resources.
    • removeOrdering

      public Resources<R> removeOrdering(boolean required, R... resources)
      Removes ordering constraints between multiple resources.
    • removeOrdering

      public Resources<R> removeOrdering(R... resources)
      Removes required ordering constraints between multiple resources.
    • getSnapshot

      public Set<R> getSnapshot()
      Gets a snapshot copy of the current set of resources, in no particular order.
    • getSorted

      public Set<R> getSorted()
      Gets the set of all resources of the given class, first with their natural ordering, then with a topological sort to manage ordering constraints.
    • isEmpty

      public boolean isEmpty()
      Gets these resources are empty.