Package org.jmock.expectation
Class Null
- java.lang.Object
-
- org.jmock.expectation.Null
-
public class Null extends java.lang.ObjectA class that represents thenullvalue. TheNullclass is used when anExpectationis set to expect nothing. Example usage:public class MockX { private Expectation... anExpectation = new Expectation...(...); public MockX() { anExpectation.setExpectNothing(); } public void setAnExpectation(Object value) { anExpectation.setExpected(value); } public void setActual(Object value) { anExpectation.setActual(value); } }The act of callingExpectation.setExpectNothing()tells the expectation that it should expect no values to change. Since allNullobjects are equal to themselves, most expectations set their expected value to an instance ofNull, and at the same time, set their actual value to another instance ofNull. This way, whenorg.jmock.expectation.Verifiable#verify()checks expectations, they will compare twoNullobjects together, which is guaranteed to succeed.- Version:
- $Id$
- Author:
- Francois Beausoleil (fbos@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_DESCRIPTIONThe default description for allNullobjects.static NullNULLA defaultNullobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)Determines equality between two objects.inthashCode()Returns thisNullobject's hashCode.java.lang.StringtoString()Returns a string representation of thisNullobject.
-
-
-
Field Detail
-
DEFAULT_DESCRIPTION
public static final java.lang.String DEFAULT_DESCRIPTION
The default description for allNullobjects. This String is equal to "Null".- See Also:
- Constant Field Values
-
NULL
public static final Null NULL
-
-
Constructor Detail
-
Null
public Null()
Instantiates a newNullobject with the default description.- See Also:
DEFAULT_DESCRIPTION
-
Null
public Null(java.lang.String description)
Instantiates a newNullobject and sets it's description.- Parameters:
description-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object other)
Determines equality between two objects.Nullobjects are only equal to another instance of themselves.- Overrides:
equalsin classjava.lang.Object- Parameters:
other-
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a string representation of thisNullobject. This merely returns the string passed to the constructor initially.- Overrides:
toStringin classjava.lang.Object
-
-