Example Usage

For example:

@RequiredArgsConstructor(staticName = "of")
public static class ComplexNumber implements Comparable<ComplexNumber> {

    @Getter private final int real;
    @Getter private final int imaginary;

    private ObjectContracts.ObjectContract<ComplexNumber> contract
            = ObjectContracts.contract(ComplexNumber.class)
                .thenUse("real", ComplexNumber::getReal)
                .thenUse("imaginary", ComplexNumber::getImaginary);


    @Override
    public boolean equals(Object o) {
        return contract.equals(this, o);
    }

    @Override
    public int hashCode() {
        return contract.hashCode(this);
    }

    @Override
    public int compareTo(final ComplexNumber other) {
        return contract.compare(this, other);
    }

    @Override
    public String toString() {
        return contract.toString(this);
    }
}

There are a number of deprecated methods that identify property names as strings. These should not be use, as they use are not type-safe and also use reflection heavily and so impose a performance hit.