Class AbstractSafeguardValidator<T>

java.lang.Object
com.atlassian.jira.bc.safeguards.AbstractSafeguardValidator<T>
Type Parameters:
T - the type of input to validate
All Implemented Interfaces:
SafeguardValidator<T>
Direct Known Subclasses:
DefaultCustomFieldLimitValidator, DefaultIssueSafeguardValidator, DefaultIssueTypeSafeguardValidator, DefaultProjectLimitValidator

public abstract class AbstractSafeguardValidator<T> extends Object implements SafeguardValidator<T>
Abstract base class for safeguard validators providing common functionality.

This class contains the common validation logic, limit checking, and breach notification mechanisms shared across different types of safeguard validators.

Since:
11.2.0
  • Field Details

  • Constructor Details

  • Method Details

    • isValid

      public boolean isValid(@Nonnull T input)
      Description copied from interface: SafeguardValidator
      Performs validation for the provided request. Implementations may also perform side effects like logging/notification when appropriate.
      Specified by:
      isValid in interface SafeguardValidator<T>
      Returns:
      true if valid (i.e., operation should be allowed)
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: SafeguardValidator
      Indicates whether the safeguard feature (and specific safeguard) is enabled.
      Specified by:
      isEnabled in interface SafeguardValidator<T>
    • notifyBreach

      protected void notifyBreach(T input, long limit, long currentCount)
    • getCurrentCount

      protected abstract long getCurrentCount()
      Gets the current count of entities being validated.
      Returns:
      the current count
    • getEntityType

      protected abstract SafeguardEntityType getEntityType()
      Gets the SafeguardEntityType for this validator.
      Returns:
      the entity type
    • getEnabledPropertyKey

      protected abstract String getEnabledPropertyKey()
      Gets the property key for the enabled flag.
      Returns:
      the enabled property key
    • getLimitPropertyKey

      protected abstract String getLimitPropertyKey()
      Gets the property key for the limit value.
      Returns:
      the limit property key
    • getEntityTypeName

      protected abstract String getEntityTypeName()
      Gets the name of the entity being validated for use in log messages.
      Returns:
      the entity type name
    • getEntityName

      protected abstract String getEntityName(T input)
      Gets the entity name from the input for breach notifications.
      Parameters:
      input - the input being validated
      Returns:
      the entity name