Package com.io7m.jaffirm.core
Class ContractCondition<T>
java.lang.Object
com.io7m.jaffirm.core.ContractCondition<T>
- Type Parameters:
T- The type of input values
- All Implemented Interfaces:
ContractConditionType<T>
An individual predicate in a contract.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ContractCondition.Builder<T>builder()Creates a builder forContractCondition.static <T> ContractCondition<T>copyOf(ContractConditionType<T> instance) Creates an immutable copy of aContractConditionTypevalue.booleanThis instance is equal to all instances ofContractConditionthat have equal attribute values.inthashCode()Computes a hash code from attributes:predicate,describer.static <T> ContractCondition<T>Construct a new immutableContractConditioninstance.toString()Prints the immutable valueContractConditionwith attribute values.final ContractCondition<T>withDescriber(Function<T, String> value) Copy the current immutable object by setting a value for thedescriberattribute.final ContractCondition<T>withPredicate(Predicate<T> value) Copy the current immutable object by setting a value for thepredicateattribute.
-
Method Details
-
predicate
- Specified by:
predicatein interfaceContractConditionType<T>- Returns:
- A predicate that must evaluate to
truefor the contract to hold
-
describer
- Specified by:
describerin interfaceContractConditionType<T>- Returns:
- A function that returns a textual description of the predicate
-
withPredicate
Copy the current immutable object by setting a value for thepredicateattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for predicate- Returns:
- A modified copy of the
thisobject
-
withDescriber
Copy the current immutable object by setting a value for thedescriberattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for describer- Returns:
- A modified copy of the
thisobject
-
equals
This instance is equal to all instances ofContractConditionthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:predicate,describer. -
toString
Prints the immutable valueContractConditionwith attribute values. -
of
Construct a new immutableContractConditioninstance.- Parameters:
predicate- The value for thepredicateattributedescriber- The value for thedescriberattribute- Returns:
- An immutable ContractCondition instance
-
copyOf
Creates an immutable copy of aContractConditionTypevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T- generic parameter T- Parameters:
instance- The instance to copy- Returns:
- A copied immutable ContractCondition instance
-
builder
Creates a builder forContractCondition.- Type Parameters:
T- generic parameter T- Returns:
- A new ContractCondition builder
-