public interface InstanceCookie extends Node.Cookie
| Modifier and Type | Interface and Description |
|---|---|
static interface |
InstanceCookie.Of
Enhanced cookie that can answer queries about the type of the
instance it creates.
|
| Modifier and Type | Method and Description |
|---|---|
Class<?> |
instanceClass()
The type that the instance is expected to be assignable to.
|
Object |
instanceCreate()
Create or obtain an instance.
|
String |
instanceName()
The name of
InstanceCookie.instanceClass(). |
String instanceName()
InstanceCookie.instanceClass().
Should be the same as instanceClass().getName()
but may be able to avoid actually loading the class.
Generally this method should not be used.
Class<?> instanceClass() throws IOException, ClassNotFoundException
Generally this method should not be used.
To test whether the instance will be assignable to some type,
use InstanceCookie.Of.instanceOf(java.lang.Class<?>) instead.
To actually load instances, use InstanceCookie.instanceCreate(); if your
objects are not naturally singletons (e.g. public no-argument constructor),
the instances should rather be of some kind of factory you define.
IOException - if metadata about the instance could not be read, etc.ClassNotFoundException - if the instance type could not be loadedObject instanceCreate() throws IOException, ClassNotFoundException
InstanceCookie) caches
previously returned instances.InstanceCookie.instanceClass()IOException - for the same reasons as InstanceCookie.instanceClass(), or an object could not be deserialized, etc.ClassNotFoundException - for the same reasons as InstanceCookie.instanceClass()