Class ContractIntCondition

java.lang.Object
com.io7m.jaffirm.core.ContractIntCondition
All Implemented Interfaces:
ContractIntConditionType

public final class ContractIntCondition extends Object implements ContractIntConditionType
An int specialized version of the ContractConditionType type.
  • Method Details

    • predicate

      public IntPredicate predicate()
      Specified by:
      predicate in interface ContractIntConditionType
      Returns:
      A predicate that must evaluate to true for the contract to hold
    • describer

      public IntFunction<String> describer()
      Specified by:
      describer in interface ContractIntConditionType
      Returns:
      A function that returns a textual description of the predicate
    • withPredicate

      public final ContractIntCondition withPredicate(IntPredicate value)
      Copy the current immutable object by setting a value for the predicate attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for predicate
      Returns:
      A modified copy of the this object
    • withDescriber

      public final ContractIntCondition withDescriber(IntFunction<String> value)
      Copy the current immutable object by setting a value for the describer attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for describer
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ContractIntCondition that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: predicate, describer.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value ContractIntCondition with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static ContractIntCondition of(IntPredicate predicate, IntFunction<String> describer)
      Construct a new immutable ContractIntCondition instance.
      Parameters:
      predicate - The value for the predicate attribute
      describer - The value for the describer attribute
      Returns:
      An immutable ContractIntCondition instance
    • copyOf

      public static ContractIntCondition copyOf(ContractIntConditionType instance)
      Creates an immutable copy of a ContractIntConditionType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable ContractIntCondition instance
    • builder

      public static ContractIntCondition.Builder builder()
      Creates a builder for ContractIntCondition.
      Returns:
      A new ContractIntCondition builder