Package com.thoughtworks.proxy.toys.nullobject

A toy to create dummy null objects with intelligent behaviour.

See:
          Description

Class Summary
Null Toy factory to create proxies acting as Null Objects.
NullInvoker A Invoker implementation that returns always new Null objects.
 

Package com.thoughtworks.proxy.toys.nullobject Description

A toy to create dummy null objects with intelligent behaviour.

The package provides a proxy factory creating proxies, that work as a dummy replacement. Main component is the Null toy, a utility class creating these proxies. Such a proxy contains an instance of a NullInvoker that handles the calls.

A null object instantiated by this toy has deterministically boring behaviour as follows:

In the follwoing example the behaviour is demonstrated by an Null object of the type File:

ProxyFactory factory = new CglibProxyFactory();
File file = (File)Null.object(File.class, factory);
System.out.println("Length is: " + file.length());
System.out.println("Exists: " + file.exists());
System.out.println("Array is empty: " + file.list().length);
System.out.println("toURL returns null, since URL is final: " + (file.toURL() == null));
System.out.println("Parent file is Null proxy: " + Null.isNullObject(file.getParentFile(), factory));