Package: org.codehaus.groovy.runtime

## [Java] Class NullObject

- org.codehaus.groovy.runtime.NullObject

-     public class NullObject
      extends GroovyObjectSupport

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `asBoolean()` A null object coerces to false.
    `` | `public Object` | `asType(Class c)` Type conversion method for null.
    `` | `public Object` | `clone()` Since this is implemented as a singleton, avoid the use of the clone method.
    `` | `public boolean` | `equals(Object o)` null is only equal to null.
    `` | `public static NullObject` | `getNullObject()` Returns the NullObject reference.
    `` | `public Object` | `getProperty(String name)` Tries to get a property on null, which fails except for "class" and "metaClass".
    `` | `public int` | `hashCode()` Returns: never
    `` | `public Object` | `invokeMethod(String name, Object arguments)` Tries to invoke a method on null, which fails.
    `` | `public boolean` | `is(Object o)` Tests for equal references.
    `` | `public Iterator` | `iterator()` iterator() method to be able to iterate on null.
    `` | `public Object` | `plus(Object o)` Fallback for `null+null`.
    `` | `public Object` | `plus(String s)` Allows to add a String to null.
    `` | `public void` | `setProperty(String name, Object value)` Tries to set a property on null, which fails.
    `` | `public String` | `toString()`
    `<T>` | `public T` | `with(Closure<T> closure)` Allows the closure to be called for NullObject.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Method Detail

    - #### public boolean asBoolean()

      A null object coerces to false.

      Returns:
        false

    - #### public Object asType(Class c)

      Type conversion method for null.

      Returns:
        null

    - #### @Override
      public Object clone()

      Since this is implemented as a singleton, avoid the use of the clone method.

      throws:
        NullPointerException
      Returns:
        never

    - #### @Override
      public boolean equals(Object o)

      null is only equal to null.

      Parameters:
        `o` - the reference object with which to compare
      Returns:
        true if this object is the same as the to argument

    - #### public static NullObject getNullObject()

      Returns the NullObject reference.

      Returns:
        the null object

    - #### @Override
      public Object getProperty(String name)

      Tries to get a property on null, which fails except for "class" and "metaClass".

      throws:
        NullPointerException
      Returns:
        never

    - #### @Override
      public int hashCode()

      throws:
        NullPointerException
      Returns:
        never

    - #### @Override
      public Object invokeMethod(String name, Object arguments)

      Tries to invoke a method on null, which fails.

      throws:
        NullPointerException
      Returns:
        never

    - #### public boolean is(Object o)

      Tests for equal references.

      Returns:
        true if object is null

    - #### public Iterator iterator()

      iterator() method to be able to iterate on null. Note: this part is from Invoker

      Returns:
        an empty iterator

    - #### public Object plus(Object o)

      Fallback for `null+null`. The plus(java.lang.String) variant catches the case of adding a non-null String to null.

      throws:
        NullPointerException
      Returns:
        never

    - #### 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.

      Returns:
        the concatenated string

    - #### @Override
      public void setProperty(String name, Object value)

      Tries to set a property on null, which fails.

      throws:
        NullPointerException

    - #### @Override
      public String toString()

    - #### <T> @Deprecated(since = "5.0.0")
      public T with(Closure<T> closure)

      Allows the closure to be called for NullObject.

      Parameters:
        `closure` - the closure to call on the object
      Returns:
        result of calling the closure