Package com.helger.http.csp
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
Abstract CSP policy declaration.
- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull AbstractCSPPolicy<T> addDirective(@NonNull T aDirective) Add a directive to this policy.boolean@NonNull StringintinthashCode()booleanisEmpty()boolean@NonNull com.helger.base.state.EChangeRemove all directives from this policy.@NonNull com.helger.base.state.EChangeremoveDirective(@Nullable T aDirective) Remove the specified directive from this policy.@NonNull com.helger.base.state.EChangeremoveDirectiveAtIndex(int nIndex) Remove the directive at the specified index.@NonNull StringtoString()
-
Constructor Details
-
AbstractCSPPolicy
public AbstractCSPPolicy()Default constructor creating an empty CSP policy.
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
trueif no directives have been added,falseotherwise.
-
isNotEmpty
public boolean isNotEmpty()- Returns:
trueif at least one directive has been added,falseotherwise.
-
getDirectiveCount
@Nonnegative public int getDirectiveCount()- Returns:
- The number of directives in this policy. Always ≥ 0.
-
addDirective
Add a directive to this policy.- Parameters:
aDirective- The directive to add. May not benull.- Returns:
- this for chaining
-
removeDirective
Remove the specified directive from this policy.- Parameters:
aDirective- The directive to remove. May benull.- Returns:
EChange.CHANGEDif the directive was removed,EChange.UNCHANGEDotherwise.
-
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.CHANGEDif the directive was removed,EChange.UNCHANGEDotherwise.
-
removeAllDirectives
public @NonNull com.helger.base.state.EChange removeAllDirectives()Remove all directives from this policy.- Returns:
EChange.CHANGEDif any directives were removed,EChange.UNCHANGEDif the policy was already empty.
-
getAsString
- Returns:
- The string representation of this policy suitable for use in an
HTTP header. Directives are separated by semicolons. Never
null.
-
equals
-
hashCode
public int hashCode() -
toString
-