Package org.codehaus.groovy.runtime
Class NullObject
java.lang.Object
groovy.lang.GroovyObjectSupport
org.codehaus.groovy.runtime.NullObject
- All Implemented Interfaces:
- GroovyObject
- 
Method SummaryModifier 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.GroovyObjectSupportgetMetaClass, setMetaClass
- 
Method Details- 
getNullObjectReturns the NullObject reference.- Returns:
- the null object
 
- 
cloneSince this is implemented as a singleton, avoid the use of the clone method.- Overrides:
- clonein class- Object
- Returns:
- never
- Throws:
- NullPointerException
 
- 
equalsnull is only equal to null.
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- Object
- Returns:
- never
- Throws:
- NullPointerException
 
- 
toString
- 
getPropertyTries to get a property on null, which fails.- Parameters:
- name- the name of the property of interest
- Returns:
- never
- Throws:
- NullPointerException
 
- 
setPropertyTries to set a property on null, which fails.- Parameters:
- name- the name of the property of interest
- value- the new value for the property
- Throws:
- NullPointerException
 
- 
invokeMethodTries to invoke a method on null, which falis.- Parameters:
- name- the name of the method to call
- arguments- the arguments to use for the method call
- Returns:
- never
- Throws:
- NullPointerException
 
- 
asBooleanpublic boolean asBoolean()A null object coerces to false.- Returns:
- false
 
- 
asTypeType conversion method for null.- Returns:
- null
 
- 
isTests for equal references.- Returns:
- true if object is null
 
- 
iteratorProvides ability to iterate on null.- Returns:
- an empty iterator
 
- 
plusFallback fornull+null. Theplus(java.lang.String)variant catches the case of adding a non-null String to null.- Returns:
- never
- Throws:
- NullPointerException
 
- 
plusAllows 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
 
- 
withAllows the closure to be called for NullObject.- Parameters:
- closure- the closure to call on the object
- Returns:
- result of calling the closure
 
 
-