ovm.polyd
Class PolyD

java.lang.Object
  extended by ovm.polyd.PolyD

public abstract class PolyD
extends java.lang.Object

The main class of PolyD: use the methods of this class to build new dispatchers.

Normally, a new dispatcher is simply built by constructing the desired interface and bodies, using annotations, and calling the static method PolyD.build(...).

A number of auxiliary variations on the main mechanism are also offered, and documented below. For more information, please consult the manual available online at http://www.ovmj.org/polyd.

See Also:
Dispatching, Invocation

Method Summary
static
<T,K extends T>
T
build(java.lang.Class<T> interf, java.lang.Object... bodies)
          Creates a new dispatcher.
static
<T,K extends T>
T
buildFromDescriptor(java.lang.Class<T> interf, java.lang.Object... bodies)
          Creates a new dispatcher from a registered Descriptor.
static
<T,K extends T>
K
buildSpecial(java.lang.Class<T> interf, java.lang.Class<K> body, java.lang.Object[] args, java.lang.Class[] argsClasses)
          Deprecated. Use build(java.lang.Class, java.lang.Object...) instead.
static
<T,K extends T>
K
buildSpecialFromDescriptor(java.lang.Class<T> interf, java.lang.Class<K> body)
          Deprecated. Use buildFromDescriptor(java.lang.Class, java.lang.Object...) instead.
static
<T,K extends T>
K
buildSpecialFromDescriptor(java.lang.Class<T> interf, java.lang.Class<K> body, java.lang.Object[] args, java.lang.Class[] argsClasses)
          Deprecated. Use buildFromDescriptor(java.lang.Class, java.lang.Object...) instead.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

build

public static <T,K extends T> T build(java.lang.Class<T> interf,
                                      java.lang.Object... bodies)
Creates a new dispatcher.

This is the main method of PolyD, used to build a dispatcher using the annotation-based mechanism. Just define the desired interface and implementing bodies, and use this method to build your new dispatcher. Normally, this is the only method of this class that you will require.

This method is not available in the pre-5.0 version of PolyD.

Parameters:
interf - the interface that defines the available messages
bodies - the list of objects belonging to the implementing classes
Returns:
the new dispatcher, which implements the supplied interface

buildSpecial

public static <T,K extends T> K buildSpecial(java.lang.Class<T> interf,
                                             java.lang.Class<K> body,
                                             java.lang.Object[] args,
                                             java.lang.Class[] argsClasses)
Deprecated. Use build(java.lang.Class, java.lang.Object...) instead.

Creates a new dispatcher from a registered Descriptor. This method could be removed from future versions of PolyD, and its use is not recommended.

This method is not available in the pre-5.0 version of PolyD.

Parameters:
interf - the interface used to build the new dispatcher
body - the class of the single body (that must implement interf)
args - the arguments used to create a new instance of body
argsClasses - the classes of the arguments used to create the new instance
Returns:
the new dispatcher, which implements the supplied interface

buildFromDescriptor

public static <T,K extends T> T buildFromDescriptor(java.lang.Class<T> interf,
                                                    java.lang.Object... bodies)
Creates a new dispatcher from a registered Descriptor.

This method is not normally necessary, and it is mainly of use in the pre-5.0 version of PolyD. The preferred approach, in that case, is building a Descriptor and then using a Factory. However, sometimes it might not be practical to deal with factories in the client code.

In those cases, after a Descriptor has been registered this method can be used to generate new matching dispatchers without using a Factory.

Parameters:
interf - the interface that defines the available messages
bodies - the list of objects belonging to the implementing classes
Returns:
the new dispatcher, which implements the supplied interface
See Also:
Descriptor, Factory

buildSpecialFromDescriptor

public static <T,K extends T> K buildSpecialFromDescriptor(java.lang.Class<T> interf,
                                                           java.lang.Class<K> body)
Deprecated. Use buildFromDescriptor(java.lang.Class, java.lang.Object...) instead.

Creates a special dispatcher from a registered Descriptor. A new instance of body will be created without passing any arguments to the constructor. This method could be removed from future versions of PolyD, and its use is not recommended.

Parameters:
interf - the interface used to build the new dispatcher
body - the class of the single body (that must implement interf)
Returns:
the new dispatcher, which implements the supplied interface

buildSpecialFromDescriptor

public static <T,K extends T> K buildSpecialFromDescriptor(java.lang.Class<T> interf,
                                                           java.lang.Class<K> body,
                                                           java.lang.Object[] args,
                                                           java.lang.Class[] argsClasses)
Deprecated. Use buildFromDescriptor(java.lang.Class, java.lang.Object...) instead.

Creates a special dispatcher from a registered Descriptor. This method could be removed from future versions of PolyD, and its use is not recommended.

Parameters:
interf - the interface used to build the new dispatcher
body - the class of the single body (that must implement interf)
args - the arguments used to create a new instance of body
argsClasses - the classes of the arguments used to create the new instance
Returns:
the new dispatcher, which implements the supplied interface