public class NullObject extends GroovyObjectSupport
Modifier and Type | Method and Description |
---|---|
boolean |
asBoolean()
A null object always coerces to false.
|
Object |
asType(Class c)
Type conversion method for null.
|
Object |
clone()
Since this is implemented as a singleton, we should avoid the
use of the clone method
|
boolean |
equals(Object to)
null is only equal to null
|
static NullObject |
getNullObject()
get the NullObject reference
|
Object |
getProperty(String property)
Tries to get a property on null, which will always fail
|
int |
hashCode() |
Object |
invokeMethod(String name,
Object args)
Tries to invoke a method on null, which will always fail
|
boolean |
is(Object other)
The method "is" is used to test for equal references.
|
Iterator |
iterator()
iterator() method to be able to iterate on null.
|
Object |
plus(Object o)
Fallback for null+null.
|
Object |
plus(String s)
Allows to add a String to null.
|
void |
setProperty(String property,
Object newValue)
Tries to set a property on null, which will always fail
|
String |
toString() |
<T> T |
with(Closure<T> closure)
Allows the closure to be called for NullObject
|
getMetaClass, setMetaClass
public static NullObject getNullObject()
public Object clone()
public Object getProperty(String property)
getProperty
in interface GroovyObject
getProperty
in class GroovyObjectSupport
property
- - the property to getpublic <T> T with(Closure<T> closure)
closure
- the closure to call on the objectpublic void setProperty(String property, Object newValue)
setProperty
in interface GroovyObject
setProperty
in class GroovyObjectSupport
property
- - the proprty to setnewValue
- - the new value of the propertypublic Object invokeMethod(String name, Object args)
invokeMethod
in interface GroovyObject
invokeMethod
in class GroovyObjectSupport
name
- the name of the method to invokeargs
- - arguments to the methodpublic boolean equals(Object to)
public Iterator iterator()
public Object plus(String s)
s
- - the String to concatenatepublic Object plus(Object o)
o
- - the Objectpublic boolean is(Object other)
other
- - the object to testpublic Object asType(Class c)
c
- - the class to convert topublic boolean asBoolean()