public class NullObject extends GroovyObjectSupport
Type Params | Return Type | Name and description |
---|---|---|
|
public boolean |
asBoolean() A null object always coerces to false. |
|
public Object |
asType(Class c) Type conversion method for null. |
|
public Object |
clone() Since this is implemented as a singleton, we should avoid the use of the clone method |
|
public boolean |
equals(Object to) null is only equal to null |
|
public static NullObject |
getNullObject() get the NullObject reference |
|
public Object |
getProperty(String property) Tries to get a property on null, which will always fail |
|
public int |
hashCode() |
|
public Object |
invokeMethod(String name, Object args) Tries to invoke a method on null, which will always fail |
|
public boolean |
is(Object other) The method "is" is used to test for equal references. |
|
public Iterator |
iterator() iterator() method to be able to iterate on null. |
|
public Object |
plus(String s) Allows to add a String to null. |
|
public Object |
plus(Object o) Fallback for null+null. |
|
public void |
setProperty(String property, Object newValue) Tries to set a property on null, which will always fail |
|
public String |
toString() |
<T> |
public T |
with(Closure<T> closure) Allows the closure to be called for NullObject |
Methods inherited from class | Name |
---|---|
class GroovyObjectSupport |
getMetaClass, setMetaClass |
A null object always coerces to false.
Type conversion method for null.
c
- - the class to convert toSince this is implemented as a singleton, we should avoid the use of the clone method
null is only equal to null
to
- - the reference object with which to compareget the NullObject reference
Tries to get a property on null, which will always fail
property
- - the property to getTries to invoke a method on null, which will always fail
name
- the name of the method to invokeargs
- - arguments to the methodThe method "is" is used to test for equal references. This method will return true only if the given parameter is null
other
- - the object to testiterator() method to be able to iterate on null. Note: this part is from Invoker
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.
s
- - the String to concatenateFallback for null+null. The result is always a NPE. The plus(String) version will catch the case of adding a non null String to null.
o
- - the ObjectTries to set a property on null, which will always fail
property
- - the proprty to setnewValue
- - the new value of the propertyAllows the closure to be called for NullObject
closure
- the closure to call on the object