Class AbstractCSPPolicy<T extends ICSPDirective>

java.lang.Object
com.helger.http.csp.AbstractCSPPolicy<T>
Type Parameters:
T - The CSP directive type
Direct Known Subclasses:
CSPPolicy

@NotThreadSafe public abstract class AbstractCSPPolicy<T extends ICSPDirective> extends Object
Abstract CSP policy declaration.
Author:
Philip Helger
  • Constructor Details

    • AbstractCSPPolicy

      public AbstractCSPPolicy()
      Default constructor creating an empty CSP policy.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns:
      true if no directives have been added, false otherwise.
    • isNotEmpty

      public boolean isNotEmpty()
      Returns:
      true if at least one directive has been added, false otherwise.
    • getDirectiveCount

      @Nonnegative public int getDirectiveCount()
      Returns:
      The number of directives in this policy. Always ≥ 0.
    • addDirective

      public @NonNull AbstractCSPPolicy<T> addDirective(@NonNull T aDirective)
      Add a directive to this policy.
      Parameters:
      aDirective - The directive to add. May not be null.
      Returns:
      this for chaining
    • removeDirective

      public @NonNull com.helger.base.state.EChange removeDirective(@Nullable T aDirective)
      Remove the specified directive from this policy.
      Parameters:
      aDirective - The directive to remove. May be null.
      Returns:
      EChange.CHANGED if the directive was removed, EChange.UNCHANGED otherwise.
    • removeDirectiveAtIndex

      public @NonNull com.helger.base.state.EChange removeDirectiveAtIndex(int nIndex)
      Remove the directive at the specified index.
      Parameters:
      nIndex - The index of the directive to remove.
      Returns:
      EChange.CHANGED if the directive was removed, EChange.UNCHANGED otherwise.
    • removeAllDirectives

      public @NonNull com.helger.base.state.EChange removeAllDirectives()
      Remove all directives from this policy.
      Returns:
      EChange.CHANGED if any directives were removed, EChange.UNCHANGED if the policy was already empty.
    • getAsString

      public @NonNull String getAsString()
      Returns:
      The string representation of this policy suitable for use in an HTTP header. Directives are separated by semicolons. Never null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public @NonNull String toString()
      Overrides:
      toString in class Object