Class NullObject
java.lang.Object
groovy.lang.GroovyObjectSupport
org.codehaus.groovy.runtime.NullObject
- All Implemented Interfaces:
GroovyObject
-
Method Summary
Modifier and TypeMethodDescriptionbooleanA null object always coerces to false.Type conversion method for null.clone()Since this is implemented as a singleton, we should avoid the use of the clone methodbooleannull is only equal to nullstatic NullObjectget the NullObject referencegetProperty(String property) Tries to get a property on null, which will always failinthashCode()invokeMethod(String name, Object args) Tries to invoke a method on null, which will always failbooleanThe method "is" is used to test for equal references.iterator()iterator() method to be able to iterate on null.Allows to add a String to null.voidsetProperty(String property, Object newValue) Tries to set a property on null, which will always failtoString()Methods inherited from class GroovyObjectSupport
getMetaClass, setMetaClass
-
Method Details
-
getNullObject
-
clone
-
getProperty
Tries to get a property on null, which will always fail- Specified by:
getPropertyin interfaceGroovyObject- Overrides:
getPropertyin classGroovyObjectSupport- Parameters:
property- - the property to get- Returns:
- a NPE
-
setProperty
Tries to set a property on null, which will always fail- Specified by:
setPropertyin interfaceGroovyObject- Overrides:
setPropertyin classGroovyObjectSupport- Parameters:
property- - the proprty to setnewValue- - the new value of the property
-
invokeMethod
Tries to invoke a method on null, which will always fail- Specified by:
invokeMethodin interfaceGroovyObject- Overrides:
invokeMethodin classGroovyObjectSupport- Parameters:
name- the name of the method to invokeargs- - arguments to the method- Returns:
- a NPE
-
equals
-
iterator
iterator() method to be able to iterate on null. Note: this part is from Invoker- Returns:
- an iterator for an empty list
-
plus
-
is
The method "is" is used to test for equal references. This method will return true only if the given parameter is null- Parameters:
other- - the object to test- Returns:
- true if other is null
-
asType
-
asBoolean
public boolean asBoolean()A null object always coerces to false.- Returns:
- false
-
toString
-
hashCode
-