Class RawRequest

java.lang.Object
com.atlassian.plugin.webresource.models.RawRequest

public final class RawRequest extends Object

Represents the specific Requestable keys a developer has explicitly included or excluded for a given request, along with the phases they should be loaded in.

The class is "raw" because it is unaware of the inter-relationships between Requestable items, such as whether or where they are included in a graph. No processing is done, nor should be done, on the inputs. Other classes may perform analysis and optimisations on the raw request.

To keep the data in this class "raw", it must only ever reference "entry points" in to a data structure (e.g., a complete DependencyGraph). Any operations that need to work with a complete, resolved list of Requestable items (e.g., resolved excluded dependencies) should use a more appropriate class to represent the result of that operation.

  • Constructor Details

    • RawRequest

      public RawRequest()
  • Method Details

    • hasAny

      public boolean hasAny(ResourcePhase phase)
      Check if anything has been requested in a given phase.
      Parameters:
      phase - the phase to check for presence of requestables.
      Returns:
      true if any requestables exist in the given resource phase, false if it is empty.
    • clearExcluded

      public void clearExcluded()
      Clear all the resources from the excluded list.
    • setPhaseCompleted

      public void setPhaseCompleted(@Nonnull ResourcePhase resourcePhase)

      Removes all resources and data requested in ResourcePhase and adds them to the excluded list.

      API note: this method mutates the object state in a non-recoverable way. if you need to know what the request was at a particular point in time, the object would need to be cloned at that point in time.

      Implementation note: since phases are sequential, this method need not exist; it could be replaced with a `getExcluded(ResourcePhase)` method, which would return all developer-excluded resources along with all included resources from all previous phases. This would allow us to make this class immutable.

    • deepClone

      @Nonnull public RawRequest deepClone()
    • exclude

      public boolean exclude(@Nonnull Requestable requestableToExclude)
      Adds a Requestable to the exclusion list of resources.
      Parameters:
      requestableToExclude - The requestable resource to be excluded.
      Returns:
      true: The requestable was added to the exclusion set. false: The requestable was not added to the exclusion set.
    • exclude

      public void exclude(@Nullable Collection<Requestable> resources)
      See Also:
    • include

      public boolean include(@Nonnull Requestable resource)
      See Also:
    • include

      public void include(@Nonnull ResourcePhase resourcePhase, @Nullable Collection<Requestable> resources)
      See Also:
    • include

      public boolean include(@Nonnull ResourcePhase resourcePhase, @Nonnull Requestable resource)
      See Also:
    • include

      public boolean include(@Nonnull ResourcePhase resourcePhase, @Nonnull RawRequest requestToInclude)
      Adds a Requestable to the inclusion list of resources for a specific type.
      Parameters:
      resourcePhase - The resource resourcePhase type for the resource.
      requestToInclude - The requestable resource to be included.
      Returns:
      true: The requestable was added to the inclusion set. false: The requestable was not added to the inclusion set.
    • includeFirst

      public void includeFirst(@Nonnull ResourcePhase resourcePhase, @Nonnull Requestable resource)
      Adds a Requestable to the inclusion list of resources for a specific type as the top of the priority.
      Parameters:
      resourcePhase - The resource resourcePhase type for the resource.
      resource - The requestable resource to be included.
    • getIncluded

      @Nonnull public LinkedHashSet<Requestable> getIncluded()
      Get a flat set with all the resources for each type. The order is not meant to be significant. However, some products depend on it.
      Returns:
      A flatted set with all the resources to be included.
      See Also:
    • getIncludedAsLooseType

      @Nonnull @Deprecated public LinkedHashSet<String> getIncludedAsLooseType()
      Deprecated.
      In the future the only method to be used will be getIncluded().
      Returns the included Requestable as their string representation for retro-compatibility. The order is not meant to be significant. However, some products depend on it.
      Returns:
      A flattened set with all the resources to be included.
      See Also:
    • getIncluded

      @Nonnull public LinkedHashSet<Requestable> getIncluded(@Nonnull ResourcePhase phaseType)
      Retrieve all the resources to be included by phase type. The order is not meant to be significant. However, some products depend on it.
      Parameters:
      phaseType - The phase type to be used for the filtering.
      Returns:
      The filtered set with the resources or empty if there is not any for the type.
      Throws:
      NullPointerException - If the resource phase type is not defined.
      See Also:
    • getIncludedData

      @Nonnull public LinkedHashMap<String,com.atlassian.json.marshal.Jsonable> getIncludedData(@Nonnull ResourcePhase phaseType)
    • getIncludedData

      @Nonnull public LinkedHashMap<String,com.atlassian.json.marshal.Jsonable> getIncludedData()
    • getExcluded

      @Nonnull public LinkedHashSet<Requestable> getExcluded()
      Returns all Requestable items whose content should not be served to the client in this request.
      Returns:
      A copy of the current excluded resources keys.
    • getExcludedAsLooseType

      @Nonnull @Deprecated public LinkedHashSet<String> getExcludedAsLooseType()
      Deprecated.
      In the future the only method to be used will be getExcluded().
      Returns the excluded Requestable as their string representation for retro-compatibility.
      Returns:
      A copy of the current excluded resources keys.
    • getExcludedData

      @Nonnull public Set<String> getExcludedData()
    • toString

      public String toString()
      Overrides:
      toString in class Object