|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Class Summary | |
|---|---|
| Null<T> | Toy factory to create proxies acting as Null Objects. |
| Null.NullBuild<T> | |
| NullInvoker | A Invoker implementation that returns always new Null objects. |
A toy to create dummy null objects with intelligent behavior.
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 behavior as follows:
List, Collections.EMPTY_LIST is returned.
Set, Collections.EMPTY_SET is returned.
Map, Collections.EMPTY_MAP is returned.
SortedSet, Null.NULL_SORTED_SET is
returned.
SortedMap, Null.NULL_SORTED_MAP is
returned.
Object, an Object is
returned.
ProxyFactory can create a proxy for the type, a
new null object for that type is returned (so you can recurse or step
through object graphs without surprises). For the standard proxy
factory this requires the return type to be an interface.
In the following example the behavior is demonstrated by an Null
object of the type File:
ProxyFactory factory = new CglibProxyFactory();
File file = Null.proxy(File.class).build(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("toURI returns null, since URI is final: " + (file.toURI() == null));
System.out.println("Parent file is Null proxy: " + Null.isNullObject(file.getParentFile(), factory));
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||