Package com.mockobjects.util
Class Null
- java.lang.Object
-
- com.mockobjects.util.Null
-
public class Null extends java.lang.Object
A class that represents thenull
value. TheNull
class is used when anExpectation
is 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 allNull
objects 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, whenverify()
checks expectations, they will compare twoNull
objects together, which is guaranteed to succeed.- Version:
- $Id: Null.java,v 1.3 2002/03/28 18:16:54 custommonkey Exp $
- Author:
- Francois Beausoleil (fbos@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_DESCRIPTION
The default description for allNull
objects.static Null
NULL
A defaultNull
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Determines equality between two objects.int
hashCode()
Returns thisNull
object's hashCode.java.lang.String
toString()
Returns a string representation of thisNull
object.
-
-
-
Field Detail
-
DEFAULT_DESCRIPTION
public static final java.lang.String DEFAULT_DESCRIPTION
The default description for allNull
objects. This String is equal to "Null
".- See Also:
- Constant Field Values
-
NULL
public static final Null NULL
-
-
Constructor Detail
-
Null
public Null()
Instantiates a newNull
object with the default description.- See Also:
DEFAULT_DESCRIPTION
-
Null
public Null(java.lang.String description)
Instantiates a newNull
object and sets it's description.- Parameters:
description
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object other)
Determines equality between two objects.Null
objects are only equal to another instance of themselves.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
-
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a string representation of thisNull
object. This merely returns the string passed to the constructor initially.- Overrides:
toString
in classjava.lang.Object
-
-