|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjdave.contract.EqualsComparableContract<T>
public abstract class EqualsComparableContract<T>
A contract which enforces the contract between equals method and Comparable interface (or Comparator interface). See the javadoc of those classes for explanation of the contract. Example usage:
<code>
Integer obj = 5;
specify(obj, should.satisfy(new EqualsComparableContract<Integer>() {
public Integer preceding() {
return 4;
}
public Integer subsequent() {
return 6;
}
public Integer equivalentByComparisonButNotByEqual() {
// There's no Integer which would be non equal with 5 and still be equal
// by comparison (compareTo() == 0). So return null.
return null;
}
});
</code>
| Constructor Summary | |
|---|---|
EqualsComparableContract()
|
|
EqualsComparableContract(Comparator<T> comparator)
|
|
| Method Summary | |
|---|---|
protected abstract T |
equivalentByComparisonButNotByEqual()
Return an instance whose compareTo is 0 with given instance, but whose equal returns false. |
void |
isSatisfied(Object obj)
|
protected abstract T |
preceding()
Return an instance which should preceed the given instance. |
protected abstract T |
subsequent()
Return an instance which should be after the given instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EqualsComparableContract()
public EqualsComparableContract(Comparator<T> comparator)
| Method Detail |
|---|
public void isSatisfied(Object obj)
throws ExpectationFailedException
isSatisfied in interface IContractExpectationFailedExceptionprotected abstract T preceding()
isSatisfied(Object)protected abstract T subsequent()
isSatisfied(Object)protected abstract T equivalentByComparisonButNotByEqual()
isSatisfied(Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||