Record Class Paths.CpdagCheckResult

java.lang.Object
java.lang.Record
edu.cmu.tetrad.graph.Paths.CpdagCheckResult
Record Components:
isLegal - Indicates whether the CPDAG is legal. A value of true means the CPDAG is legal, while false means it is not.
violation - The violation encountered in the CPDAG if it is illegal. This value is null when isLegal is true.
detail - Additional information providing specific details about the violation, if any. This value is null when isLegal is true.
Enclosing class:
Paths

public static record Paths.CpdagCheckResult(boolean isLegal, Paths.CpdagViolation violation, String detail) extends Record
Represents the result of a CPDAG legality check.

This class encapsulates the status of whether the CPDAG is legal or not, the specific violation if it is not legal, and an optional detailed explanation.

Version:
$Id: $Id
Author:
josephramsey
  • Constructor Details

    • CpdagCheckResult

      public CpdagCheckResult(boolean isLegal, Paths.CpdagViolation violation, String detail)
      Creates an instance of a CpdagCheckResult record class.
      Parameters:
      isLegal - the value for the isLegal record component
      violation - the value for the violation record component
      detail - the value for the detail record component
  • Method Details

    • legal

      public static Paths.CpdagCheckResult legal()
      Creates a CpdagCheckResult instance representing a legal CPDAG.

      This method provides a standardized way to indicate the legality of a CPDAG when no violations or additional details exist.

      Returns:
      A CpdagCheckResult object with isLegal set to true, and both violation and detail set to null.
    • illegal

      public static Paths.CpdagCheckResult illegal(Paths.CpdagViolation violation, String detail)
      Creates an CpdagCheckResult instance indicating an illegal CPDAG.

      This method is used when a CPDAG check fails due to a violation. It encapsulates the specific violation and an optional detailed explanation.

      Parameters:
      violation - The specific CpdagViolation encountered. This parameter must not be null.
      detail - Additional details about the violation, which can provide more context or clarification. This may be null if no further details are necessary.
      Returns:
      A CpdagCheckResult object with isLegal set to false, containing the specified violation and detail.
    • toString

      public String toString()
      Returns a string representation of the CPDAG legality check result.

      If the CPDAG is legal, the string "Legal CPDAG" is returned. Otherwise, a string describing the violation and any additional details is returned.

      Specified by:
      toString in class Record
      Returns:
      A string describing the legality of the CPDAG. For legal CPDAGs, returns "Legal CPDAG". For illegal CPDAGs, returns a description of the violation and optional details.
    • 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 the compare method from their corresponding wrapper classes.
      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.
    • isLegal

      public boolean isLegal()
      Returns the value of the isLegal record component.
      Returns:
      the value of the isLegal record component
    • violation

      public Paths.CpdagViolation violation()
      Returns the value of the violation record component.
      Returns:
      the value of the violation record component
    • detail

      public String detail()
      Returns the value of the detail record component.
      Returns:
      the value of the detail record component