Record Class ConstraintRef

java.lang.Object
java.lang.Record
ai.timefold.solver.core.api.score.constraint.ConstraintRef
Record Components:
packageName - The constraint package is the namespace of the constraint. When using a ConstraintConfiguration, it is equal to the ConstraintWeight.constraintPackage(). It is not recommended for the user to set this, or to read its value; instead, the user should use whatever the solver provided as default and not rely on this information at all. The entire concept of constraint package is likely to be removed in a future version of the solver.
constraintName - The constraint name. It might not be unique, but constraintId() is unique. When using a ConstraintConfiguration, it is equal to the ConstraintWeight.value().
constraintId - Always derived from packageName and constraintName.
All Implemented Interfaces:
Comparable<ConstraintRef>

public record ConstraintRef(@NonNull String packageName, @NonNull String constraintName, String constraintId) extends Record implements Comparable<ConstraintRef>
Represents a unique identifier of a constraint.

Users should have no need to create instances of this record. If necessary, use of(String, String) and not the record's constructors.

  • Constructor Details

    • ConstraintRef

      public ConstraintRef(@NonNull String packageName, @NonNull String constraintName, String constraintId)
      Creates an instance of a ConstraintRef record class.
      Parameters:
      packageName - the value for the packageName record component
      constraintName - the value for the constraintName record component
      constraintId - the value for the constraintId record component
  • Method Details

    • of

      public static ConstraintRef of(String packageName, String constraintName)
    • parseId

      public static ConstraintRef parseId(String constraintId)
    • composeConstraintId

      public static String composeConstraintId(String packageName, String constraintName)
    • toString

      public 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
    • compareTo

      public int compareTo(ConstraintRef other)
      Specified by:
      compareTo in interface Comparable<ConstraintRef>
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • packageName

      public @NonNull String packageName()
      Returns the value of the packageName record component.
      Returns:
      the value of the packageName record component
    • constraintName

      public @NonNull String constraintName()
      Returns the value of the constraintName record component.
      Returns:
      the value of the constraintName record component
    • constraintId

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