Groovy 1.7.0

org.codehaus.groovy.runtime
Class NullObject

java.lang.Object
  groovy.lang.GroovyObjectSupport
      org.codehaus.groovy.runtime.NullObject

class NullObject
extends GroovyObjectSupport

Constructor Summary
private NullObject()

private constructor

 
Method Summary
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(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()

 
Methods inherited from class GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Constructor Detail

NullObject

private NullObject()
private constructor


 
Method Detail

asType

public Object asType(Class c)
Type conversion method for null.
param:
c - the class to convert to
return:
always null


clone

public Object clone()
Since this is implemented as a singleton, we should avoid the use of the clone method


equals

public boolean equals(Object to)
null is only equal to null
param:
to - the reference object with which to compare
return:
- true if this object is the same as the to argument


getNullObject

public static NullObject getNullObject()
get the NullObject reference
return:
the null object


getProperty

public Object getProperty(String property)
Tries to get a property on null, which will always fail
param:
property - the property to get
return:
a NPE


hashCode

public int hashCode()


invokeMethod

public Object invokeMethod(String name, Object args)
Tries to invoke a method on null, which will always fail
param:
name the name of the method to invoke
param:
args - arguments to the method
return:
a NPE


is

public boolean is(Object other)
The method "is" is used to test for equal references. This method will return true only if the given parameter is null
param:
other - the object to test
return:
true if other is null


iterator

public Iterator iterator()
iterator() method to be able to iterate on null. Note: this part is from Invoker
return:
an iterator for an empty list


plus

public Object plus(String s)
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.
param:
s - the String to concatenate
return:
the concatenated string


setProperty

public void setProperty(String property, Object newValue)
Tries to set a property on null, which will always fail
param:
property - the proprty to set
param:
newValue - the new value of the property


toString

public String toString()


 

Copyright © 2003-2009 The Codehaus. All rights reserved.