public class Null
extends java.lang.Object
null
value.
The Null
class is used when an
Expectation
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 calling
Expectation.setExpectNothing()
tells the expectation that it should expect no values to change. Since
all Null
objects are equal to themselves,
most expectations set their expected value to an instance of
Null
, and at the same time, set their actual
value to another instance of Null
.
This way, when org.jmock.expectation.Verifiable#verify()
checks
expectations, they will compare two Null
objects together, which is guaranteed to succeed.Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
DEFAULT_DESCRIPTION |
The default description for all
Null
objects. |
static Null |
NULL |
A default
Null object. |
Constructor | Description |
---|---|
Null() |
Instantiates a new
Null object with
the default description. |
Null(java.lang.String description) |
Instantiates a new
Null object and
sets it's description. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(java.lang.Object other) |
Determines equality between two objects.
|
int |
hashCode() |
Returns this
Null object's hashCode. |
java.lang.String |
toString() |
Returns a string representation of this
Null
object. |
public static final java.lang.String DEFAULT_DESCRIPTION
Null
objects.
This String is equal to "Null
".public static final Null NULL
public Null()
Null
object with
the default description.DEFAULT_DESCRIPTION
public Null(java.lang.String description)
Null
object and
sets it's description.description
- public boolean equals(java.lang.Object other)
Null
objects are only equal to
another instance of themselves.equals
in class java.lang.Object
other
- public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
Null
object.
This merely returns the string passed to the constructor initially.toString
in class java.lang.Object