Package org.codehaus.groovy.runtime
Class NullObject
java.lang.Object
groovy.lang.GroovyObjectSupport
org.codehaus.groovy.runtime.NullObject
- All Implemented Interfaces:
 GroovyObject
- 
Method Summary
Modifier and TypeMethodDescriptionbooleanA null object coerces to false.Type conversion method for null.clone()Since this is implemented as a singleton, avoid the use of the clone method.booleannull is only equal to null.static NullObjectReturns the NullObject reference.getProperty(String name) Tries to get a property on null, which fails.inthashCode()invokeMethod(String name, Object arguments) Tries to invoke a method on null, which falis.booleanTests for equal references.iterator()Provides ability to iterate on null.Fallback fornull+null.Allows to add a String to null.voidsetProperty(String name, Object value) Tries to set a property on null, which fails.toString()<T> TAllows the closure to be called for NullObject.Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass 
- 
Method Details
- 
getNullObject
Returns the NullObject reference.- Returns:
 - the null object
 
 - 
clone
Since this is implemented as a singleton, avoid the use of the clone method.- Overrides:
 clonein classObject- Returns:
 - never
 - Throws:
 NullPointerException
 - 
equals
null is only equal to null. - 
hashCode
public int hashCode()- Overrides:
 hashCodein classObject- Returns:
 - never
 - Throws:
 NullPointerException
 - 
toString
 - 
getProperty
Tries to get a property on null, which fails.- Parameters:
 name- the name of the property of interest- Returns:
 - never
 - Throws:
 NullPointerException
 - 
setProperty
Tries to set a property on null, which fails.- Parameters:
 name- the name of the property of interestvalue- the new value for the property- Throws:
 NullPointerException
 - 
invokeMethod
Tries to invoke a method on null, which falis.- Parameters:
 name- the name of the method to callarguments- the arguments to use for the method call- Returns:
 - never
 - Throws:
 NullPointerException
 - 
asBoolean
public boolean asBoolean()A null object coerces to false.- Returns:
 - false
 
 - 
asType
Type conversion method for null.- Returns:
 - null
 
 - 
is
Tests for equal references.- Returns:
 - true if object is null
 
 - 
iterator
Provides ability to iterate on null.- Returns:
 - an empty iterator
 
 - 
plus
Fallback fornull+null. Theplus(java.lang.String)variant catches the case of adding a non-null String to null.- Returns:
 - never
 - Throws:
 NullPointerException
 - 
plus
Allows to add a String to null. The result is concatenated String of the result of calling toString() on this object and the String in the parameter.- Returns:
 - the concatenated string
 
 - 
with
Allows the closure to be called for NullObject.- Parameters:
 closure- the closure to call on the object- Returns:
 - result of calling the closure
 
 
 -