Record Class ComplianceRule

java.lang.Object
java.lang.Record
com.cloudforgeci.api.core.rules.ComplianceRule
Record Components:
ruleId - Unique identifier for this compliance rule (e.g., "SOC2-CC6.1", "PCI-DSS-Req3.4")
description - Human-readable description of the requirement
configRuleId - Optional AWS Config rule ID that monitors this requirement
passed - Whether the validation check passed
errorMessage - Optional error message if validation failed

public record ComplianceRule(String ruleId, String description, Optional<String> configRuleId, boolean passed, Optional<String> errorMessage) extends Record
Represents a compliance rule with its validation status and AWS Config rule mapping.

This structured approach links compliance validation to actual AWS Config rules, providing traceability between framework requirements and infrastructure monitoring.

  • Constructor Details

    • ComplianceRule

      public ComplianceRule(String ruleId, String description, Optional<String> configRuleId, boolean passed, Optional<String> errorMessage)
      Creates an instance of a ComplianceRule record class.
      Parameters:
      ruleId - the value for the ruleId record component
      description - the value for the description record component
      configRuleId - the value for the configRuleId record component
      passed - the value for the passed record component
      errorMessage - the value for the errorMessage record component
  • Method Details

    • pass

      public static ComplianceRule pass(String ruleId, String description, String configRuleId)
      Create a passing compliance rule.
    • pass

      public static ComplianceRule pass(String ruleId, String description)
      Create a passing compliance rule without Config rule mapping.
    • fail

      public static ComplianceRule fail(String ruleId, String description, String errorMessage)
      Create a failing compliance rule with error message.
    • fail

      public static ComplianceRule fail(String ruleId, String description, String configRuleId, String errorMessage)
      Create a failing compliance rule with Config rule mapping.
    • toErrorString

      public Optional<String> toErrorString()
      Convert to legacy string error format for CDK validation.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • ruleId

      public String ruleId()
      Returns the value of the ruleId record component.
      Returns:
      the value of the ruleId record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • configRuleId

      public Optional<String> configRuleId()
      Returns the value of the configRuleId record component.
      Returns:
      the value of the configRuleId record component
    • passed

      public boolean passed()
      Returns the value of the passed record component.
      Returns:
      the value of the passed record component
    • errorMessage

      public Optional<String> errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component